2012-03-10 29 views
0

我使用下面的代碼我發現SO的iPhone應用程序我工作,HTML5:如何在使用Onclick自定義按鈕時暫停?

<a onclick="this.firstChild.play()"> 
    <audio src=".."></audio> 
    Here's where I insert my custom player button 
</a> 

但我不能暫停音樂,任何人都可以告訴我,我應該在哪裏插入pause()

回答

2

如何讓你開始?測試它here on this Fiddle

<audio id="player" src=".."></audio> 

<a href="javascript:;" onclick="document.getElementById('player').play();">Play</a> 
<a href="javascript:;" onclick="document.getElementById('player').pause();">Pause</a> 
+0

嗨,謝謝Lloyd!我只是試過在瀏覽器上完美地工作。但是因爲我將這個用於iPhone應用程序,所以只有實際播放音樂,是否可以在其中添加其他代碼以用於暫停功能? – babyjaz 2012-03-10 22:43:14

+0

此代碼將在iPhone瀏覽器或UIWebView – Lloyd 2012-03-10 22:55:46

+0

工作更改我的答案使用'a'標籤,而不是'按鈕' – Lloyd 2012-03-10 22:57:35

相關問題