gpt4 book ai didi

ios - 下载时播放 Mp4 和 Mp3 文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:42:09 28 4
gpt4 key购买 nike

我想播放一个音频和视频文件,但我没有这些文件的 URL。我现在正在使用 AFNetwork 下载文件,文件数据是字节形式的。

[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) 
{
float val = (float)totalBytesRead / totalBytesExpectedToRead;
if(!isStart && val >= 0.5)
{
isStart = YES;

UIWindow *window = [UIApplication sharedApplication].keyWindow;

window = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIWebView * webView = [[UIWebView alloc]initWithFrame:window.frame];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];

[webView loadRequest:urlRequest];
[window addSubview:webView];
}
}];

但是 UIWebView 没有打开这个文件我也使用了 MPMoviePlayer 但没有任何反应。请告诉我这是否可能是部分下载的文件。

最佳答案

您可以使用 MPMoviePlayerController 流播放电影:

NSURL *fileURL = [NSURL URLWithString:@"http://www.website.com/video.mp4"];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[moviePlayerController play];
[self.view addSubview:_moviePlayerController.view];

关于ios - 下载时播放 Mp4 和 Mp3 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17524757/

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