gpt4 book ai didi

objective-c - 从 Objective-C 中的 url 播放 youtube 电影

转载 作者:行者123 更新时间:2023-11-28 22:47:44 26 4
gpt4 key购买 nike

我有一个包含 YouTube 网址的表格 View 。

http://www.youtube.com/v/M67PNWvKdg0&autoplay=1

我正在尝试使用以下代码播放视频文件。我还导入了媒体框架。

  Video *video = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSURL *urlString=[NSURL URLWithString:video.url];
//NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
//pathForResource:@"Video1" ofType:@"mp4"]];

MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:urlString];

[self presentMoviePlayerViewControllerAnimated:playercontroller];

playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

[playercontroller.moviePlayer play];


playercontroller = nil;

它现在所做的是弹出一个电影播放器​​,然后立即返回到我的表格 View 。有人知道问题出在哪里吗?

提前致谢

最佳答案

您使用的是 iOS 6 吗?我发现通过 MPMoviePlayerController 播放 Youtube 视频有困难,所以我发现了 this非常有用。

这只有 MPMoviePlayerController...这也适用于 < iOS 6 版本。

关于objective-c - 从 Objective-C 中的 url 播放 youtube 电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12777061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com