2013-07-17 18 views
0

我開發了我的第一個諾基亞網絡應用程序。我嘗試播放聲音,保存在本地存儲,當按鈕點擊諾基亞網絡應用播放聲音

這是我的代碼,但它不工作

<div class="odd" id="g" onclick="playSound('s40-theme/sounds/piano_G.mp3')"></div> 

<script type="text/javascript">  
    function playSound(file) { 
    var embed = document.createElement("embed"); 

    embed.setAttribute('src', file); 
    embed.setAttribute('hidden', true); 
    embed.setAttribute('autostart', true); 

    document.body.appendChild(embed); 
} 
</script> 

回答

1

您的代碼不起作用,因爲嵌入標籤不支持S40 Web應用程序。 This page列出了所有支持的標籤。

this FAQ中給出的示例指示您使用loadUrl方法。在應用程序的背景中無法播放聲音。以下示例將下載該文件,用戶將在本地音頻播放器中播放該文件。

實施例:

<a href="#" onclick="mwl.loadURL('path_to_file.mp3');">Play sound</a>