好吧,所以我有一个合理的大小项目,我正在使用jquery主干和其他几个javascript库.我想知道我的javascript库是否应该有一个文件而我的自定义代码应该有另一个文件.或者一堆单独的javascript文件.
这一整天都在扼杀我,但我不知道如何让html5视频播放器在没有原生控件的情况下工作.
我想要没有任何控件,但如果我不包含它们,视频似乎不想播放,即使我在下面添加一些javascript试图强制它播放,它适用于iPhone和多个浏览器,但不是iPad这是奇怪的,任何想法?
如果它有帮助,这里有一些标记!
<video src="video.mp4" id="video" poster="image.jpg" onclick="this.play();"/></video>
$('#video').click(function(){
document.getElementById('video').play();
});
Run Code Online (Sandbox Code Playgroud) 我正在使用这个解决方案http://daverupert.com/2012/05/making-video-js-fluid-for-rwd/,以使videojs播放器流畅.我的问题是,当我有多个视频(每个都有一个唯一的ID),我不知道如何使这项工作.
这是我的开发网站,我有3个视频,http://tweedee.e-mediaresources.info/
以下是我为玩家提供的代码(来自Dave Rupert的解决方案):
<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>
Run Code Online (Sandbox Code Playgroud)
这段代码适用于一个视频,但我怎么做多个ids …
我有一个html页面,我需要在其中添加多个canvas元素并在页面加载时加载它.
function draw()
{
var c=document.getElementById("myCanvas");
var padding = 20;
var ctx=c.getContext("2d");
var grd=ctx.createLinearGradient(0,0,175,50);
grd.addColorStop(0,"#E05D1B");
grd.addColorStop(1,"#00FF00");
ctx.fillStyle=grd;
ctx.fillRect(0,0,275,50);
}
<canvas id="myCanvas" width="250" height="8" style="margin-bottom:10px;margin-left:10px;">
<img src="images\gradient1.png" style="margin-bottom:10px;margin-left:10px;"/>
</canvas>
Run Code Online (Sandbox Code Playgroud)
我添加像这个代码与不同的ID,但我需要重新编码的JavaScript; 我怎么能减少它?
<canvas id="myCanvas1" width="250" height="8" style="margin-bottom:10px;margin-left:10px;"> <img src="images\gradient1.png" style="margin-bottom:10px;margin-left:10px;"/> </canvas>
Run Code Online (Sandbox Code Playgroud) javascript ×4
html5 ×3
canvas ×2
jquery ×2
video ×2
html ×1
html5-video ×1
ipad ×1
performance ×1
video.js ×1
web ×1