ios - how can i auto play a video in my app using wkwebview -


i using wkwebview show site. , site have video. when site showed,the video cannot autoplay.is method let video auto play?

following function worked me giving support of auto play

- (void)loadwebviewtoplay {      nsstring * videohtml = @"<html><head><style>body{margin:0px 0px 0px 0px;}</style></head> <body> <div id=\"player\"></div> <script> var tag = document.createelement('script'); tag.src = 'http://www.youtube.com/player_api'; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); var player; function onyoutubeplayerapiready() { player = new yt.player('player', { width:'200', height:'200', videoid:'bhqqvyy5kyo', events: { 'onready': onplayerready } }); } function onplayerready(event) { event.target.playvideo(); } </script> </body> </html>";      uiwebview * webview = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 200, 200)];     webview.backgroundcolor = [uicolor clearcolor];     webview.opaque = no;     //videoview.delegate = self;     [self.view addsubview:webview];     webview.mediaplaybackrequiresuseraction = no;      [webview loadhtmlstring:videohtml baseurl:[[nsbundle mainbundle] resourceurl]];  } 

for more can reference iframe_api_reference or player_parameters


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -