简体   繁体   English

如何播放/暂停Flash视频(不是HTML5 <video> )与Jquery

[英]How to play/pause flash video(not html5 <video>) with Jquery

I am looking into which should be simple actions such as playing and pausing a simple flash video with Jquery when a button or play pause button is clicked, and I can't find anything online. 我正在寻找应该采取的简单操作,例如单击按钮或播放暂停按钮时播放和暂停带有Jquery的简单Flash视频,而我在网上找不到任何内容。

<object style="display: block;" type="application/x-shockwave-flash" data="//vjs.zencdn.net/4.0/video-js.swf" id="video-239-video_flash_api" name="video-239-video_flash_api" class="vjs-tech" height="100%" width="100%">

The above object tag is the element for the flash. 上面的object标签是flash的元素。 My script is located at the header and the object tag is located way lower at the body. 我的脚本位于标题处,而object标签位于正文的下方。 I have tried something like 我已经尝试过类似的东西

$('#video-239-video_flash_api').get(0).play();

and

$('#video-239-video_flash_api').play();

but nothing works just to play and pause a flash video. 但仅播放和暂停Flash视频没有任何效果。

"...but nothing works just to play and pause a flash video." “ ...但是,仅播放和暂停Flash视频没有任何效果。”

I think the whole selling point of VideoJS is that it makes the Flash video (FLV file) work within a browser's <video> tag. 我认为VideoJS的整个卖点在于,它使Flash视频(FLV文件)在浏览器的<video>标签内工作。

The example code below is tested on Windows PC with Chrome browser. 以下示例代码已在装有Chrome浏览器的Windows PC上进行了测试。 Just paste in a new html document and try it. 只需粘贴一个新的html文档并尝试。 Hopefully it gives you some useful hints. 希望它给您一些有用的提示。

<!DOCTYPE html>
<html>
<head>
<link href="http://vjs.zencdn.net/4.7/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.7/video.js"></script>
</head>

<body>
<h1>flash test</h1>

<video id="myPlayer" class="video-js vjs-default-skin"  preload="auto" width="800" height="335" 
data-setup='{}'>
<source src="http://www.mediacollege.com/video-gallery/testclips/20051210-w50s.flv" type='video/x-flv'>
</video>


<button onclick="playVideo()">Play</button>
<button onclick="pauseVideo()">Pause</button>

<script type="text/javascript">

var myPlayer;

videojs("myPlayer").ready
( function() { myPlayer = this; } );

function playVideo() { myPlayer.play(); }

function pauseVideo() { myPlayer.pause(); }

</script>

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM