簡體   English   中英

如何播放/暫停Flash視頻(不是HTML5 <video> )與Jquery

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

我正在尋找應該采取的簡單操作,例如單擊按鈕或播放暫停按鈕時播放和暫停帶有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%">

上面的object標簽是flash的元素。 我的腳本位於標題處,而object標簽位於正文的下方。 我已經嘗試過類似的東西

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

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

但僅播放和暫停Flash視頻沒有任何效果。

“ ...但是,僅播放和暫停Flash視頻沒有任何效果。”

我認為VideoJS的整個賣點在於,它使Flash視頻(FLV文件)在瀏覽器的<video>標簽內工作。

以下示例代碼已在裝有Chrome瀏覽器的Windows PC上進行了測試。 只需粘貼一個新的html文檔並嘗試。 希望它給您一些有用的提示。

<!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