There's no way method to do autoplay video on android platform?

时光毁灭记忆、已成空白 提交于 2019-12-02 07:58:53

问题


I read in billions of foruns and posts on the stackoverflow, and nothing. When I found a solution or something like that, not work anymore.

I tried with Google API and nothing too.

I can autoplay video in the IOS native player, putting de direct mp4 link on tag ''

But in Android, I try with iframe, video tag, direct mp4 link, nothing works.

There's no way to do this works on the Android platform?


回答1:


 <div id="player"></div>
<script>
       var tag = document.createElement('script');
       tag.src = "https://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', {
                  height: '480',
                  width: '853',
                  videoId: 'YOUR ID',
                  events: {
                       'onReady': onPlayerReady,
                       'onStateChange': onPlayerStateChange
                  },
                  playerVars: {
                        'autoplay': 1,
                        'showinfo': 0,
                        'controls': 0
                                }
                            });
                        }
                        function onPlayerReady(event) {
                            event.target.playVideo();
                        }

                        var done = false;
                        function onPlayerStateChange(event) {
                            if (event.data == YT.PlayerState.PLAYING && !done) {
                                done = true;
                            }
                        }
                        function stopVideo() {
                            player.stopVideo();
                        }
                    </script> 



回答2:


When you use the Player in a browser that has Flash disabled, playback is handled via HTML5 tags.

Apple explicitly prohibits autoplaying media in tags in iOS Safari.

This is also the case for at least recent versions the default Android Browser or in Chrome. I'd strongly suspect that Android Firefox has the same restriction.




回答3:


   <iframe src='http://www.youtube.com/embed/bhRqrw82P3A?autoplay=1&modestbranding=1&showinfo=0&fs=0' width='300' height='175' frameborder='0' >
    </iframe>


来源:https://stackoverflow.com/questions/21281039/theres-no-way-method-to-do-autoplay-video-on-android-platform

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