How to play youtube video in UIWebView muted?

可紊 提交于 2019-12-01 10:40:20
Muhammad Zeeshan

First of all you cannot set the volume using javascript check this doc and read Volume Control in JavaScript section. Found here.

Secondly i tried this:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(playerItemBecameCurrentNotif:)
                                             name:@"AVPlayerItemBecameCurrentNotification"
                                           object:nil];


- (void)playerItemBecameCurrentNotif:(NSNotification*)notification {
    AVPlayerItem *playerItem = notif.object;
    AVPlayer *player = [playerItem valueForKey:@"player"];
    [player setVolume:0.0];
}

This seems to be working fine in simulator. However this method is using some private properties. Use at your own risk ;) and don't forget to remove observer.

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