Wideo osadzone w Youtube: funkcja autoplay nie działa w iPhonie
Mam link youtube osadzony wideo na stronie HTML5, który chcę autoplay.
Poniższy kod działa w przeglądarkach, ale w iPhonie; nie działa i wymaga dodatkowego kliknięcia.
<iframe type="text/html" width="125" height="100" src="http://www.youtube.com/embed/d_g0251EfB8?autoplay=1" frameborder="0"></iframe>
Co robić
47
Author: Daniel Daranas, 2011-11-15
3 answers
Nie da się tego zrobić. Z różnych powodów (w tym, ale nie ograniczając się do wykorzystania danych) Firma Apple nie zezwala na automatyczne odtwarzanie filmów.
65
Author: Mike,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:21
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:21
Próbowałem z następujących I Youtube wideo pomyślnie autoplays w trybie pełnoekranowym, gdy Widok sieci Web zakończyć ładowanie:
[self.webView setAllowsInlineMediaPlayback:YES];
[self.webView setMediaPlaybackRequiresUserAction:NO];
[self.view addSubview:self.webView];
NSString* embedHTML = [NSString stringWithFormat:@"\
<html>\
<body style='margin:0px;padding:0px;'>\
<script type='text/javascript' src='http://www.youtube.com/iframe_api'></script>\
<script type='text/javascript'>\
function onYouTubeIframeAPIReady()\
{\
ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})\
}\
function onPlayerReady(a)\
{ \
a.target.playVideo(); \
}\
</script>\
<iframe id='playerId' type='text/html' width='100%%' height='%f' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=0&autoplay=1' frameborder='0'allowfullscreen>\
</body>\
</html>",self.webView.frame.size.height,@"Dw9jFO_coww"];
[self.webView bringSubviewToFront:self.btnBack];
self.webView.backgroundColor = [UIColor clearColor];
self.webView.opaque = NO;
[self.webView loadHTMLString:embedHTML baseURL:[[NSBundle mainBundle] resourceURL]];
3
Author: Apurv Soni,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-30 06:37:03
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-30 06:37:03
UPDATE:
IOS 10 + umożliwia teraz automatyczne odtwarzanie na elementach HTML5 , wystarczy wyciszyć dźwięk na elementach. Youtube nadal nie będzie. Android jest nadal SOL zbyt, ale hej, to początek!
Próbka:
<video autoplay muted>
<source src="movie.mp4" type="video/mp4">
Sadly, your browser does not support the video tag X_x
</video>
Źródło informacji: https://webkit.org/blog/6784/new-video-policies-for-ios/
0
Author: Lux.Capacitor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-02 18:15:54
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-02 18:15:54