2015-06-08 66 views
0

任何人都可以幫助我如何讓我的嵌入式視頻在Ionic框架中加載時自動播放。如何在離子框架中自動播放嵌入式視頻?

例子:我有一個視頻按鈕,然後當我點擊它,它會直接進入到視頻,然後自動播放它提前

+0

看看這個鏈接:https://developer.mozilla.org/nl/ docs/Web/Guide/HTML/HTML5_audio_en_video_gebruiken – devqon

+0

.mov文件支持離子還是android? –

回答

0

在iOS中,HTML視頻僅在用戶輸入時開始。您無法在ios Safari中控制此行爲。因爲你提到'Ionic Framework',我假設你正在用Cordova/PhoneGape/Ionic構建器構建一個應用程序?您可以設置<preference name="MediaPlaybackRequiresUserAction" value="true"/>到config.xml文件http://cordova.apache.org/docs/en/4.0.0/guide_platforms_ios_config.md.html

嵌入的播放器:

<div id="ytplayer"></div> 

<script> 
    // Load the IFrame Player API code asynchronously. 
    var tag = document.createElement('script'); 
    tag.src = "https://www.youtube.com/player_api"; 
    var firstScriptTag = document.getElementsByTagName('script')[0]; 
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 

    // Replace the 'ytplayer' element with an <iframe> and 
    // YouTube player after the API code downloads. 
    var player; 
    function onYouTubePlayerAPIReady() { 
    player = new YT.Player('ytplayer', { 
     height: '390', 
     width: '640', 
     videoId: 'M7lc1UVf-VE', 
     autoplay : 1 
    }); 
    } 
</script> 

https://developers.google.com/youtube/player_parameters

相關問題