gpt4 book ai didi

iphone - MPMoviePlayerController "Loading Movie..."

转载 作者:太空狗 更新时间:2023-10-30 03:46:49 26 4
gpt4 key购买 nike

我正在尝试在装有 iOS 4.1 的 iPhone 上播放资源文件夹中的视频文件。 MPMoviePlayerViewController 显示该 View ,但它只会随着事件指示器的旋转而永远显示“正在加载电影...”。任何人都知道这是什么原因?我试过各种应该在 iPhone 上运行的视频格式,每次都得到相同的结果。

电影播放器​​响应显示和隐藏控件等操作。

我的代码:

-(void) playVideoNamed:(NSString *)videoName
{
// I get the path like this so the user can enter extension in the filename
NSString *path = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath], videoName];
NSLog(@"Path of video file: %@", path);

RootViewController *rootController = [(DerpAppDelegate *)[[UIApplication sharedApplication] delegate] viewController];

NSURL *url = [NSURL URLWithString:path];

MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
vc.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

[rootController presentMoviePlayerViewControllerAnimated:vc];
[vc.moviePlayer prepareToPlay]; // Not sure about this... I've copied this code from various others that claims this works
[vc.moviePlayer play];
}

最佳答案

发现问题:

NSURL *url = [NSURL URLWithString:path];

必须替换为:

NSURL *url = [NSURL fileURLWithPath:path];

很难发现那个...

关于iphone - MPMoviePlayerController "Loading Movie...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6070975/

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