gpt4 book ai didi

ios - MPMoviePlayerViewController 不播放

转载 作者:行者123 更新时间:2023-11-29 04:05:26 24 4
gpt4 key购买 nike

我会保持简单,代码如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
VideoEntry *entry = [videoEntries objectAtIndex:indexPath.row];

[HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:entry.url] completeBlock:^(NSDictionary *videoDictionary, NSError *error) {
NSArray *urls = [videoDictionary allValues];
NSURL *url = [NSURL URLWithString:[urls objectAtIndex:0]];
[mp.moviePlayer setAllowsAirPlay:YES];
[mp.moviePlayer setContentURL:url];
[mp.moviePlayer prepareToPlay];
[mp.moviePlayer play];
[self presentMoviePlayerViewControllerAnimated:mp];
}];

}

mp 是一个 MPMoviePlayerViewController。 View Controller 出现了,但电影没有开始,它只是说“正在加载...”,在你问之前我100%确定链接有效。

谢谢!

最佳答案

它不起作用,因为主线程上未调用完成 block 。您可以通过强制在主线程上执行代码来解决:

[HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:entry.url]
completeBlock:^(NSDictionary *videoDictionary, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
NSArray *urls = [videoDictionary allValues];
NSURL *url = [NSURL URLWithString:[urls objectAtIndex:0]];
[mp.moviePlayer setAllowsAirPlay:YES];
[mp.moviePlayer setContentURL:url];
[mp.moviePlayer prepareToPlay];
[mp.moviePlayer play];
[self presentMoviePlayerViewControllerAnimated:mp];
});
}];

关于ios - MPMoviePlayerViewController 不播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15342609/

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