我使用以下代码在我的iPhone5S上通过WebView播放youtube或vimeo视频:
<WebView ref='webview' javaScriptEnabled={true} scrollEnabled={true} automaticallyAdjustContentInsets={false} style={itemStyles.webView} url={videoUrl} onShouldStartLoadWithRequest={false} startInLoadingState={false} allowsInlineMediaPlayback={true} scalesPageToFit={false} />webview组件可以正确显示视频,但不幸的是,它是静默的,没有音频。
如何为webview组件启用音频?
谢谢
发布于 2016-03-25 10:47:21
好吧,对不起,我自己找到了答案:
我需要做的是在AppDelegate.m文件中放置一段代码:
首先导入AVFoundation库:
#import <AVFoundation/AVFoundation.h>然后,在didFinishLaunchingWithOptions方法中插入以下代码:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback
error:&setCategoryError];一切都会好起来的。
https://stackoverflow.com/questions/36213194
复制相似问题