Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Why wont looping work on android player? — Gideros Forum

Why wont looping work on android player?

In my game I have a track set up to loop forever. This works when I use the desktop player. However, when I test the game on the android player on my smartphone, the music only plays once and then it stops. Everything else works fine except for this. Does anybody know why this is happening? Thanks!
Tagged:

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited September 2018
    It appears that some versions of Android in combination with some MP3 files don't like to repeat properly.

    This is from my game code, it repeats properly on everything I've tried.
    musicSfx={}
    musicSfx[1]=Sound.new("music/starbase.mp3")
    --musicSfx[2]=Sound.new("music/Mutation - Spirogyra.mp3")
    currentMusic=0
    musicVolume=0.8
    effectsVolume=1
    playingMusic=nil
     
    function restartMusic()
    	playingMusic:removeEventListener(Event.COMPLETE,restartMusic)
    	playingMusic=musicSfx[currentMusic]:play()
    	if playingMusic then
    		playingMusic:setVolume(musicVolume)
    		playingMusic:addEventListener(Event.COMPLETE,restartMusic)
    	else
    		currentMusic=0
    	end
    end
     
    function playMusic(song,force)
    	if song~=currentMusic or force then
    		if musicSfx[song] then
    			if playingMusic and playingMusic:isPlaying() then
    				playingMusic:stop()
    			end
    			playingMusic=musicSfx[song]:play()
    			if playingMusic then
    				currentMusic=song
    				playingMusic:setVolume(musicVolume)
    				playingMusic:addEventListener(Event.COMPLETE,restartMusic)
    			else
    				currentMusic=0
    			end
    		end
    	end
    end
     
    function volumeMusic(vol)
    	musicVolume=vol
    	if playingMusic then
    		if vol>0 then
    			if playingMusic:isPaused() then
    				playingMusic:setPaused(false)
    			end
    			playingMusic:setVolume(vol)
    		else
    			playingMusic:setPaused(true)
    		end
    	end
    end
     
    playMusic(1)

    Likes: antix

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @SinisterSoft I have yet to find an MP3 file that does repeat correctly! Once you know about the whole restarting event it's not a giant issue but it is mildly annoying that you cannot have a proper looping sound in Gideros without using WAV files since the MP3 restart event always leave a noticeable gap :(
  • SinisterSoftSinisterSoft Maintainer
    edited September 2018
    I have no problem the files repeating on some of my devices, but others don't - the safest way is the event. It may be because Android uses the media player for playing MP3 (because MP3 playback can be done in hardware on a lot of chipsets), if it was done in software then it may not be an issue - but it would eat up CPU time.

    The media player may be the responsibility of the device manufacturer, so some may have bugs?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Maybe a solution would be for Gideros to not set repeat mode and to use an event to check and replay if the flag was set (rather than 'setLooping'). maybe it does this already and there is a bug?

    https://stackoverflow.com/questions/15324522/repeating-looping-a-mp3-n-no-no-times-in-android-programming-depending-on-user
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • It seems that ogg files doesn't have this issue, and they are usually smaller than mp3 :)
  • ogg files are played using the CPU, so your game is slower.

    Likes: Apollo14

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Really? I didn't notice that
  • It will be a small % and you will only see a difference if mp3 is played in hardware - on a lot of phones it is but it depends on the media player/chipset.

    Likes: pie

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.