【发布时间】:2015-10-07 11:04:01
【问题描述】:
我使用 flowplayer 作为我的 html5 视频播放器 (https://flowplayer.org/latest/)。我添加了一个额外的按钮供用户在用户点击视频后播放视频。它在我的笔记本电脑或台式机上运行良好,只要用户点击“播放视频”按钮,视频就会播放。
但是,当我在我的手机或我朋友的手机或任何其他手机(已尝试所有 iphone 和一些 android)上测试时,视频无法播放。
因此,我尝试在桌面上使用 google chrome 进行调试并激活移动模式。每当我单击该按钮时,它都会在控制台上给我这个错误“Uncaught TypeError: Cannot read property 'play' of undefined”。但是当我退出移动模式时,它又可以正常工作而不会出现任何错误。
你知道我该如何解决这个问题吗?谢谢。
<html>
<head>
<!-- player skin -->
<link rel="stylesheet" href="skin/functional.css">
<!-- site specific styling -->
<style>
body { font: 12px "Myriad Pro", "Lucida Grande", sans-serif; text-align: center; padding-top: 5%; }
.flowplayer { width: 80%; }
</style>
<!-- for video tag based installs flowplayer depends on jQuery 1.7.2+ -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- include flowplayer -->
<script src="flowplayer.min.js"></script>
</head>
<body>
<!-- the player -->
<div>
<div class="player" style="width:50%;" data-embed="false">
<!-- <di class="player" data-embed="false" data-swf="flowplayer.swf" data-ratio="0.4167"> -->
<video id="player">
<source type="video/webm" src="https://stream.flowplayer.org/bauhaus.webm">
<source type="video/mp4" src="https://stream.flowplayer.org/bauhaus.mp4">
</video>
</div>
<button id="playbutton">Play Video</button>
</div>
</body>
</html>
<script>
// run script after document is ready
$(function () {
$('#playbutton').click(function(e){
$('#player').get(0).play();
});
});
</script>
【问题讨论】:
标签: javascript android jquery html video