经过大量测试,我发现视频属性的顺序对在 mediaelement 中正确播放视频有很大的影响。使用以下设置可让您在所有浏览器中播放 youtube 视频并调整其大小。myvids div 上 50% 的宽度看起来很奇怪,但没有它,视频在 IE 中的大小将不正确。在这一点上,我只有一个要解决的问题。在 iPad 上打开时,播放按钮会移动到视频的左上角。如果我在视频上设置宽度和高度而不是百分比,则播放按钮会正确显示,但播放器不会调整大小。
<div class="myvids" id="viddivap1" width="50%" style="width:100%;position:relative;">
<video class="thevid" width="640" height="360" style="max-width:100%;height:100%;" id="my_video_ap1" preload="auto" autoplay controls="controls" >
<source type="video/youtube" src="http://www.youtube.com/watch?v=FAGL9gxhdHM" />
<span style="color:white;">Your browser does not support HTML5, Flash, or Silverlight. Please update your browser.</span>
</video>
</div>
$('video').mediaelementplayer({
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// width of audio player
audioWidth: 400,
// height of audio player
audioHeight: 30,
// initial volume when the player starts
startVolume: 0.8,
// useful for <audio> player loops
loop: false,
// enables Flash and Silverlight to resize to content size
enableAutosize: true,
// the order of controls you want on the control bar (and other plugins below)
features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
// Hide controls when playing and mouse is not over the video
alwaysShowControls: false,
// force iPad's native controls
iPadUseNativeControls: false,
// force iPhone's native controls
iPhoneUseNativeControls: false,
// force Android's native controls
AndroidUseNativeControls: false,
// forces the hour marker (##:00:00)
alwaysShowHours: false,
// show framecount in timecode (##:00:00:00)
showTimecodeFrameCount: false,
// used when showTimecodeFrameCount is set to true
framesPerSecond: 25,
// turns keyboard support on and off for this instance
enableKeyboard: true,
// when this player starts, it will pause other players
pauseOtherPlayers: true,
// array of keyboard commands
keyActions: []
});