0

I have developed my first nokia web app . I am trying to play sound which saved in local storage when button clicked

this is my code but it doesn't work

<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>
jmt
  • 223
  • 1
  • 8
  • 28

1 Answers1

1

Your code does not work because the embed tag is not supported in S40 Web Apps. This page lists all the supported tags.

The example given in this FAQ instructs you to use the loadUrl method. There is no way to play a sound in the background of the app. The following example will download the file and the user will play it in the native audio player.

Example:

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

igordsm
  • 464
  • 2
  • 8