0
當我嘗試以下操作時,正在播放的視頻在雙擊時停止,但新視頻不播放。我只是得到一個黑屏。更改MPMoviePlayerController的內容
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 2;
[self.moviePlayer.view addGestureRecognizer:tap];
- (void)handleTap:(UITapGestureRecognizer *)gesture {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Movie2" ofType:@"mp4"];
[self.moviePlayer setContentURL:[NSURL fileURLWithPath:moviePath]];
NSLog(@"contentURL: %@", self.moviePlayer.contentURL);
}
日誌語句中正確顯示文件://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/15072262-7BC0-42D5-840C-740CF5B97D55/MyApp.app/ Movie2.mp4
Movie2.mp4是有效的,如果我在第一次創建MPMoviePlayerController時將其設置爲contentURL,則播放。爲什麼我不能更改播放器的內容?
您是否訂閱了所有通知?也許它試圖告訴你發生了什麼,你只是忽略它而已...... – jsd 2012-03-30 23:32:58