gpt4 book ai didi

ios - 无法在 MPMovieplayercontroller 中播放电影

转载 作者:行者123 更新时间:2023-11-28 19:56:39 24 4
gpt4 key购买 nike

我无法在 MPMovieplayercontroller 中播放电影。我在谷歌上搜索了很多,但每次都是黑屏。我还尝试检查 isPreparedToPlay 属性,但它始终为 false。

self.moviePlayer = [[MPMoviePlayerController alloc] init];

[self.moviePlayer setContentURL:[self.videos objectAtIndex:0]];
NSLog(@"Playing videos : %@", [self.moviePlayer contentURL]);

NSLog(@"Playing videos : %@", [[self.moviePlayer contentURL] absoluteString]);

[self.moviePlayer.view setFrame:CGRectMake (0, 0, 320, 460)];
[self.view addSubview:self.moviePlayer.view];
//self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
/*[self.moviePlayer.view setFrame:self.view.bounds];
[self.moviePlayer prepareToPlay];
[self.moviePlayer setShouldAutoplay:NO];*/
[self.moviePlayer play];

首先 NSLog 打印出一些奇怪的东西(为什么有“...”?):

/Users/Athos/Library/Developer/CoreSimulator/Devices/15855707-E728-4542-8DAA-3B71362D7DB6/data/Containers/Data/Applicati ... unny.mp4

但是第二个很好(我手动检查文件是否在那里:

/Users/Athos/Library/Developer/CoreSimulator/Devices/15855707-E728-4542-8DAA-3B71362D7DB6/data/Containers/Data/Application/2ACD0002-1A1E-484C-B4E4-9486EBCFF74A/Documents/BuckBunny.mp4

你有什么线索吗?提前致谢

最佳答案

self.moviePlayer = [[MPMoviePlayerController alloc] init];
[self.moviePlayer setContentURL:[NSURL fileURLWithPath:[self.videos objectAtIndex:0]]];
// Use FileURLWithPath

关于ios - 无法在 MPMovieplayercontroller 中播放电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137923/

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