久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

具有動態源的 HTML5 音頻元素

HTML5 audio element with dynamic source(具有動態源的 HTML5 音頻元素)
本文介紹了具有動態源的 HTML5 音頻元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個基本的音頻播放器:

I have a basic audio player:

<audio controls="controls" autoplay="true" loop="loop">
<source src="song.php" type="audio/mpeg" />
</audio>

而不是直接指向 MP3 文件的源代碼,我讓它指向一個 PHP 文件,然后該文件指向 MP3 文件,該文件有效.但是,當當前曲目結束時,PHP 文件將指向一個新的 MP3 文件.所以,我遇到的問題是,當播放器使用新的 MP3 文件循環播放時,它完全停止工作.有沒有辦法解決?有沒有辦法通過播放列表或任何其他播放器來做到這一點?

And instead of the source pointing directly to the MP3 file I have it pointed at a PHP file which then points to the MP3 file, which works. But, when the current track is over the PHP file is pointing to a new MP3 file. So, the problem that I have is that when the player goes to loop, with the new MP3 file, it completely stops working. Is there any way around this? Is there a way to do this with a playlist or any other players?

推薦答案

復制自您的重復問題:

對于初學者來說,每次單擊元素時都會附加一個新的事件處理程序.如果有人經常暫停音樂,他們就會遇到問題.

For starters, you are attaching a new event handler every single time the element is clicked. If someone frequently pauses the music, they will run into problems.

相反,試試這個:

<audio id="audio" autoplay controls src="song.php" type="audio/mpeg"></audio>
<script type="text/javascript">
    document.getElementById('audio').addEventListener("ended",function() {
        this.src = "song.php?nocache="+new Date().getTime();
        this.play();
    });
</script>

我假設 song.php 是一個返回音頻數據的 PHP 文件.nocache 查詢參數將確保每次實際調用該文件.

I'm assuming that song.php is a PHP file that returns the audio data. The nocache query parameter will ensure that the file is actually called every time.

這篇關于具有動態源的 HTML5 音頻元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 精品1区2区| 国产精品一区二区不卡 | 日韩欧美视频免费在线观看 | 亚洲网站在线观看 | 一区二区三区四区在线 | 欧美激情在线精品一区二区三区 | 黄色免费网站在线看 | 国产乱码精品一区二区三区中文 | 国产视频中文字幕 | 一级毛片黄片 | 国产日韩欧美精品一区二区 | 久草视频在线播放 | 亚洲看片 | 91社区在线观看高清 | 精产国产伦理一二三区 | 日韩无| 亚洲成人一二区 | 精一区二区 | 波波电影院一区二区三区 | 亚洲区一| 99re热这里只有精品视频 | 欧美精品一区二区免费视频 | 国产成人jvid在线播放 | av香港经典三级级 在线 | 精品96久久久久久中文字幕无 | www.黄网 | 日日夜夜狠狠操 | 亚洲激情av| 成人h视频| 亚洲精品久久嫩草网站秘色 | 精品成人佐山爱一区二区 | 国产亚洲精品久久久久久豆腐 | 日韩免费在线视频 | 久久久国产精品一区 | 国产一区2区 | 精品视频免费在线 | 精品久久av | 久婷婷| 精品亚洲一区二区三区 | 日韩视频精品在线 | 中文字幕成人 |