我使用這個解決方案,http://daverupert.com/2012/05/making-video-js-fluid-for-rwd/,使videojs玩家流體。我的問題是當我有多個視頻(每個都有一個唯一的ID),我不知道如何使這項工作。多響應的Video.js球員
這是我開發的網站我有3個視頻,http://tweedee.e-mediaresources.info/
這裏是我的代碼有玩家(從上面戴夫·魯珀特的解決方案):
<script type="text/javascript">
// Once the video is ready
_V_('#my_video_1').ready(function(){
var myPlayer = this; // Store the video object
var aspectRatio = 9/16; // Make up an aspect ratio
function resizeVideoJS(){
// Get the parent element's actual width
var width = document.getElementById(myPlayer.id).parentElement.offsetWidth;
// Set width to fill parent element, Set height
myPlayer.width(width).height(width * aspectRatio);
}
resizeVideoJS(); // Initialize the function
window.onresize = resizeVideoJS; // Call the function on resize
});
</script>
此代碼工作正常的一個視頻,但我怎麼做多個ID?正如你可以在我的開發網站看到的,我只是複製了三次以上的腳本(每個都有一個不同的ID),並且只會導致最後一個視頻變得流暢。
是......這確實與調整所有三名球員幫助。任何想法,但如何鞏固的JS,所以它不是相同的腳本複製3次(它的作品,但它是醜陋的和不高效的)? – Patrick