在webview中播放mp3文件时出现Quicktime
当我使用 webview 播放 mp3 文件时,会出现快速播放器。然而,我注意到这不一定会发生在其他设备上,即,对于其他 iPhone,mp3 文件会继续播放,但快速播放器不会出现。结果,用户无法快进/暂停等 mp3 文件。
有什么方法可以严格强制显示 QuickTime 播放器吗?
这是我的代码 NSURL *myUrl = [NSURL URLWithString: self.url];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:myUrl cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];
NSLog(@"Play URL: %@", self.url);
UIWebView *webView2 = [[UIWebView alloc] init];
[webView2 loadRequest: request];
[request release];
when i use a webview to play an mp3 file, the quick time player appears. However, i notice that this does not necessarily happen to other devices i.e., for other iphones, the mp3 file continue playing but the quick time player does not appear. As a result, user is unable to fast forward/pause etc. the mp3 file.
Is there any way that i can strictly enforce that the quicktime player appears?
Here is my code
NSURL *myUrl = [NSURL URLWithString: self.url];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:myUrl cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];
NSLog(@"Play URL: %@", self.url);
UIWebView *webView2 = [[UIWebView alloc] init];
[webView2 loadRequest: request];
[request release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,快速播放器没有出现很可能是一个错误。这是 iOS 5.0 beta 版本之一中的一个已知错误。通常,WebKit 会从 HTTP 标头或文件扩展名中检测内容类型,并从那里打开 AVPlayer。您可以尝试使用
NSMutableURLRequest
并设置内容类型标头。[[myRequest headers] setObject:@"video/mp4" forKey:@"Content-Type"]
The fact the quick time player didn't appear may well be a bug. It's a know bug in one of the iOS 5.0 beta releases. Normally WebKit will detect the content type from the HTTP header or file extension and open the AVPlayer from there. You could try using an
NSMutableURLRequest
and setting the content type header.[[myRequest headers] setObject:@"video/mp4" forKey:@"Content-Type"]