Software Archive
Read-only legacy content
17060 Discussions

playing wav files in xdk

ophelia_l_
Beginner
439 Views

Before the last update I was able to play wav files using this code

now with the latest update of xdk I am not able to play wav files

script placed in the head tag of the html5 page

<script> function EvalSound(soundobj) { var thissound=document.getElementById(soundobj); thissound.Play(); } </script>

 

code placed in body of the html5

<embed src="bob.wav" autostart=true width=100 height=100 id="sound1" enablejavascript="true">

can you tell me what code I would use to play sound in XDK latest version

0 Kudos
4 Replies
Dale_S_Intel
Employee
439 Views

I have some questions about your example.  Do you ever call the function 'EvalSound'?  Also, the id of the embed element (sound1) doesn't match the id in the call to getElementById (soundobj), so I'm not sure if the javascript code is supposed to be related to the embed element or not.

If you're just trying to play it as an HTML element, I would recommend looking into the audio element - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio.

0 Kudos
ophelia_l_
Beginner
439 Views

I played it using the audio element but it does not play in the emulator.. however when I push it to the test server in app viewer it plays.  Any idea of how I can get it played with the emulator.  I remember the same thing used to happen with the video tag in the previous version.

0 Kudos
ophelia_l_
Beginner
439 Views

my video code shows in xdk but does not play in the emulator

<video width="320" height="240" controls>
  <source src="song.mp4" type="video/mp4">
  <source src="song.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

0 Kudos
PaulF_IntelCorp
Employee
439 Views

Take a look at this example. In particular, the btnBarkHTML5() function inside the main.js file.

0 Kudos
Reply