针对带有 mediaelements 的小型设备
我对 mediaelement.js 的使用
到目前为止,
非常好,当我定位小型设备时,我只是遇到了一个小问题,视频不会自动调整为新的设备大小
,我怀疑 #containingBlock 有问题,所以我尝试定位它与媒体查询
我已经尝试过 Chris Coyer 对响应式视频的建议 响应式视频教程 但它搞砸了 mediaelement.js 的输出,
也许有人知道我如何为 iphone 发布喜欢的内容,
我的页面可以在 我的页面< /a>
我使用以下 html 来嵌入我的视频
<div id="containingBlock">
<video id="introVid" poster="http://med-innovation.com/wp-content/themes/med/images/video_start.png" controls="control" preload="none">
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.mp4" type="video/mp4" />
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.webm" type="video/webm" />
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.ogv" type="video/ogg" />
<object type="application/x-shockwave-flash" data="http://med-innovation.com/wp-content/themes/med/build/flashmediaelement.swf">
<param name="movie" value="http://med-innovation.com/wp-content/themes/med/build/flashmediaelement.swf" />
<param name="flashvars" value="controls=true&file=http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.mp4" />
<img src="http://med-innovation.com/wp-content/themes/med/images/fail.jpg" width="640" height="360" title="Il n'est pas possible de visionner une video avec votre navigateur" />
</object>
</video>
<script>
jQuery(document).ready(function($)
{
// declare object for video
var player = new MediaElementPlayer('#introVid',
{
// if the <video width> is not specified, this is the default
defaultVideoWidth: 640,
// if the <video height> is not specified, this is the default
defaultVideoHeight: 360,
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// 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','loop','current','progress','duration','volume'],
success: function (mediaElement, domObject)
{
// add event listener
mediaElement.addEventListener('ended', function(e)
{
window.location = "http://med-innovation.com/choice/";
}, false);
}
});
});
</script>
和我拥有的 css
video {width: 100% !important; height: auto !important;}
#containingBlock {
width: 640px;
height: 360px;
margin: 0 auto;
text-align:center;
}
@media(max-width: 520px)
{
#page-wrap, #colophon {width: auto; margin: 7px auto; }
#containingBlock {
width: 100%;
height: 100%;
margin: 0 auto;
text-align:center;
}
}
I'm playing around with mediaelement.js
very good so far
I just face a little problem when I target small devices, the video is not automatically resized to the new device size
I suspect the #containingBlock to be problematic, so I tried to target it with media query
I have tried Chris Coyer suggestion for responsive video
responsive video tutorial
but it screws what mediaelement.js outpout
maybe someone have an idea on how I can issue for iphone likes
my page is available at my page
I use the following html to embed my videos
<div id="containingBlock">
<video id="introVid" poster="http://med-innovation.com/wp-content/themes/med/images/video_start.png" controls="control" preload="none">
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.mp4" type="video/mp4" />
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.webm" type="video/webm" />
<source src="http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.ogv" type="video/ogg" />
<object type="application/x-shockwave-flash" data="http://med-innovation.com/wp-content/themes/med/build/flashmediaelement.swf">
<param name="movie" value="http://med-innovation.com/wp-content/themes/med/build/flashmediaelement.swf" />
<param name="flashvars" value="controls=true&file=http://med-innovation.com/wp-content/themes/med/media/ElevatorPitch.mp4" />
<img src="http://med-innovation.com/wp-content/themes/med/images/fail.jpg" width="640" height="360" title="Il n'est pas possible de visionner une video avec votre navigateur" />
</object>
</video>
<script>
jQuery(document).ready(function($)
{
// declare object for video
var player = new MediaElementPlayer('#introVid',
{
// if the <video width> is not specified, this is the default
defaultVideoWidth: 640,
// if the <video height> is not specified, this is the default
defaultVideoHeight: 360,
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// 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','loop','current','progress','duration','volume'],
success: function (mediaElement, domObject)
{
// add event listener
mediaElement.addEventListener('ended', function(e)
{
window.location = "http://med-innovation.com/choice/";
}, false);
}
});
});
</script>
and on the css I have
video {width: 100% !important; height: auto !important;}
#containingBlock {
width: 640px;
height: 360px;
margin: 0 auto;
text-align:center;
}
@media(max-width: 520px)
{
#page-wrap, #colophon {width: auto; margin: 7px auto; }
#containingBlock {
width: 100%;
height: 100%;
margin: 0 auto;
text-align:center;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道您提到了 Chris Coyier 和那个教程,但是请查看同一个人专门针对视频响应能力而开发的这个插件。
http://fitvidsjs.com/
祝你好运
i know you mentioned Chris Coyier and that tutorial, but check out this plug in by the same person specifically for video responsiveness.
http://fitvidsjs.com/
good luck