当用户在我的tableview中选择一行时,我试图从youtube流式传输视频, 继承人代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *videoURLString = [self.listaVideos objectAtIndex:[indexPath row]];
NSURL *videoURL = [NSURL URLWithString:videoURLString];
self.theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:[self.theMovie moviePlayer]];
[self.view addSubview:self.theMovie.view];
[self.theMovie setWantsFullScreenLayout:NO];
[self presentMoviePlayerViewControllerAnimated:theMovie];
[[self.theMovie moviePlayer] play];
}
-(void)moviePlayBackDidFinish:(NSNotification*)notification
{
NSLog(@"ENded");
}
错误:Unbalanced calls to begin/end appearance transitions for <MPMoviePlayerViewController: 0x7a256a0>.
答案 0 :(得分:0)
尝试删除
[self.view addSubview:self.theMovie.view];
您似乎将其添加到视图中,然后呈现它。 (如果您不想呈现它,请删除该行)
答案 1 :(得分:0)
MPMoviePlayerViewController
无法播放YouTube视频。
哦,也是Amit Shah所说的(移除addSubview:
会处理不平衡的电话,但不能播放视频)。
答案 2 :(得分:0)
以下是来自youtube url的视频代码。如果你真的想从Youtube上播放视频流,那么依靠下面的代码就很容易了。事件你不需要太多关心事件处理,缓冲等......
@interface VideoPlayerContrl : UIViewController {
IBOutlet UIWebView *youtubeVideo;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *htmlString = @"<html><head>\n"
"<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>\n"
"<body style=\"background:#F00;margin-top:0px;margin-left:0px\">\n"
"<div><object width=\"212\" height=\"172\">\n"
"<param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param>\n"
"<param name=\"wmode\" value=\"transparent\"></param>\n"
"<embed src=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"\n"
"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"247\" height=\"178\"></embed>\n"
"</object></div></body></html>\n";
[youtubeVideo loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"https://s3.amazonaws.com/adplayer/colgate.mp4"]];
}
希望能解决你的问题:)