【问题标题】:Video is not playing from URL视频未从 URL 播放
【发布时间】:2014-09-23 09:35:51
【问题描述】:

我在服务器 url 中上传了视频,并将 URL 传递给 MPMoviePlayerController 以自动播放视频,但视频没有播放,我得到了黑页。当我使用本地视频时,它正在播放。

NSURL *fileURL = [NSURL URLWithString:@"server.net/projects/media/videos/023.mp4"];

 NSLog(@"Magento url is %@", fileURL);

 moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

 [[moviePlayerController view] setFrame:CGRectMake(100,200, 600, 500)];

 [moviePlayerController setShouldAutoplay:YES];

 [moviePlayerController setControlStyle:MPMovieControlStyleEmbedded];

 [[moviePlayerController backgroundView] setBackgroundColor:[UIColor clearColor]];

 [moviePlayerController prepareToPlay];


 [self.view addSubview:moviePlayerController.view];

【问题讨论】:

  • 您的网址已损坏,无法指向视频文件
  • 没有。视频正在浏览器中播放
  • 如果是你当地的环境,那么好吧,对我不起作用
  • 现在对你来说是否适用于 http://?

标签: ios objective-c mpmovieplayercontroller mpmoviewcontroller


【解决方案1】:

我假设播放器不加载视频的原因是你应该在开头添加http://

【讨论】:

    【解决方案2】:

    试试这个

    #import <MediaPlayer/MediaPlayer.h>
    
    
    //MPMoviePlayer
        NSURL *fileURL = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
        NSLog(@"Magento url is %@", fileURL);
    
        MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
        [[moviePlayerController view] setFrame:CGRectMake(0, 0, 320, 568)];
        [moviePlayerController setShouldAutoplay:YES];
        [moviePlayerController setControlStyle:MPMovieControlStyleEmbedded];
        [[moviePlayerController backgroundView] setBackgroundColor:[UIColor clearColor]];
        [moviePlayerController prepareToPlay];
    
        [self.view addSubview:moviePlayerController.view];
    
        [moviePlayerController play];
    

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 2015-03-09
      • 2019-02-22
      • 2016-10-02
      • 2017-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多