31993

Android Java LibGDX Music, Sound

What is difference between Sound and Music types in LibGDX?

Music gameMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/gamemusic.mp3")); gameMusic.play();

This worked both on desktop and Android but this one

Sound gameMusic = Gdx.audio.newSound(Gdx.files.internal("sound/gamemusic.mp3")); gameMusic.play();

this worked on desktop but doesnt play sound on android.

Answer1:

Music is streamed, while Sound is loaded into memory. (Because Android with libgdx has limit of 1mb file for 'sound', Music can be of greater size)

It is said so here:

https://github.com/libgdx/libgdx/wiki/Sound-effects

https://github.com/libgdx/libgdx/wiki/Streaming-music

And according to another question on SO, you must wait a frame before you can play a Sound directly after loading: No Sound in Android Application with Libgdx

Recommend

  • Alternative to readfile()
  • AVAudioPlayer doesn't load sound
  • How to crop a mp3 in ASP.NET + C#?
  • three.js WebVR example code works on threejs.org but not on my local server
  • Receive custom intent without activity restart
  • Android NFC read Tags issue. Activity starts each time on data received
  • Disabling sound of embedded flash object with html
  • How to get real device model in Android?
  • Why does Sencha 2 only work in Webkit browsers?
  • Change device language on Android 6.0 (Android M)
  • Android - Calling Java from Webview
  • GeoTrust SSL certificate on Android not trusted
  • You tube videos are not playing
  • Why isn't my “Fizz Buzz” test in R working?
  • AlertDialog style when using setView()
  • What is the difference between a “service account” and an “installed application”?
  • Problems with toDataURL HTML5 other ways to get canvas data?
  • Find JSON nested nodes using multiple string values
  • How can go in last activity with resume button?
  • How to set elevation color?
  • Clear fused location provider's location for testing
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • Implicit joins and Where in Doctrine - how?
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Button text different than value submitted in query string
  • MS Access - How to change the linked table path by amend the table
  • Limiting recursion to certain level - Duplicate rows
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Window Size for Mac application
  • Release, debug version and Authorization Google?
  • Adding custom controls to a full screen movie
  • WOWZA + RTMP + HTML5 Playback?
  • log4net write single file for each call to log.info
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Converting MP3 duration time
  • How to load view controller without button in storyboard?