Flash can't play WAV

Monkey Targets Forums/Flash/Flash can't play WAV

Xaron(Posted 2012) [#1]
Hi all,

I can't play a simple wav file in the flash target. Here's my test code:

Strict

Import mojo
Global testApp:Test

Function Main:Int()
  testApp = New Test()
  Return 0
End Function

Class Test Extends App
  Field sfx:Sound

  Method OnCreate:Int()
    sfx = LoadSound( "swoosh.wav" )
    SetUpdateRate(30)
    Return 0
  End Method

  Method OnUpdate:Int()
    Return 0
  End Method
  
  Method OnSuspend:Int()
    Return 0
  End Method
  
  Method OnResume:Int()
    Return 0
  End Method

  Method OnRender:Int()
    Cls()
    DrawText( "Press left mouse button to play a sound!", 10, 10 )
    If( TouchDown( 0 ) ) Then PlaySound( sfx )
    Return 0
  End Method

End Class


Link to the wav: http://www.xaron.net/dl/monkey/swoosh.wav

Complete project: http://www.xaron.net/dl/monkey/flashtest.zip


Xaron(Posted 2012) [#2]
Ok... looks like it's my fault. V51 Flash can only play MP3, right? But I can add it to V52 via the config.txt...

edit: NO BUG. Sorry for that. Flash can only do MP3. Ok, need to read the documentation better. ;)


DruggedBunny(Posted 2012) [#3]
Moved to Flash forum as it may still help others!


Hima(Posted 2012) [#4]
Yes, this is not a problem with Monkey but with Flash itself. Flash can only play mp3 out of the box. If you want it to support other formats (.ogg, or other chiptunes format) you have to find 3rd party code or library that add this functionality.


Paul - Taiphoz(Posted 2012) [#5]
I'm trying to play .mp3 files and its not making a sound.