Embedded UIWebView YouTube Volume

牧云@^-^@ 提交于 2019-12-08 05:14:07

问题


I'm working on an iOS app that can display YouTube videos in a UIWebView. Everything is working great except...

The first time a video is played it plays at ~10% volume. The device volume is set at 100% and the player volume shows 100% in the UI. Backing out of the web view and play a song in the app using our native streaming player then go back to the video it plays at the correct volume.

Things that don't work...


- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [[MPMusicPlayerController applicationMusicPlayer] setVolume:1.0];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [[MPMusicPlayerController iPodMusicPlayer] setVolume:1.0];
}

Both calls just flash the volume changed UI on screen and do nothing for the WebView volume.

If you have any ideas that would be greatly appreciated.


回答1:


After some more research I just needed to set the playback type back from the built in audio player.

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL ok;
NSError *setCategoryError = nil;
ok = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];

Something along those lines.



来源:https://stackoverflow.com/questions/14445418/embedded-uiwebview-youtube-volume

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!