在MPMediaPlayback内播放imdb视频无法正常工作

时间:2012-09-08 06:45:23

标签: iphone objective-c video

我从预告片的imdb中获取视频网址,例如:

http://video-http.media-imdb.com/MV5BMjM2OTAxNDA2Nl5BMTFeQW1wNF5BbWU3MDYwMDA4OTY@.mp4?Expires=1347051666&Signature=4OPreoHNu1wcEMX2UIkKYvnu1y7r9NG6qoLf5w1egm7D-5UVSZI6KAZkxX5BA9h7Zj88LZEEWowBbgdh2CC8Zdr2syj1IL4Ncew~rqgLvuBRkwbHyIJzag2CBXEblmAHkMR3NRoOxy93iUXMvZrNj2pnxuYjF9Bf9AODrBxmUdc_&Key-Pair-Id=APKAILW5I44IHKUN2DYA

添加其余代码:

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; 
    [moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)]; 
    [self.view addSubview:moviePlayerController.view];

我只收到此错误(在模拟器中,未在设备上试过):

Error getting audio input device sample rate

此致 米尔扎

1 个答案:

答案 0 :(得分:1)

尝试下面的代码

NSString *url = [NSString stringWithFormat:@"Url"];

    mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];

    [[mp moviePlayer] prepareToPlay];
    [[mp moviePlayer] setUseApplicationAudioSession:NO];
    [[mp moviePlayer] setShouldAutoplay:YES];
    [[mp moviePlayer] setControlStyle:2];
    [[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
    [self presentMoviePlayerViewControllerAnimated:mp];