Background music stops playing a minute into the game

In the game I made, the sound stops playing after about a minute after and when paused, it starts playing a minute after
I used audio.loadStream to load and play the sound;

The music file I used is a 39 seconds long and 932 kb

I use it for the background music

Well, the solution might be very simple. If you have the following code in your app, then just remove it.
 

local function stopAudio() audio.stop( backgroundMusicChannel ) end timer.performWithDelay( 60000+math.random(-5000,5000), stopAudio )

If you don’t happen to have this exact, or very similar piece of code in your app, then please share enough of your code, as well as the audio file, to replicate that issue so that others may try to help you. Sharing a sample project with the issue, zipping it and uploading it here would be the easiest method of getting help.

I’m sorry if I came across as a jerk, but you cannot realistically expect others to be able to help you if you only tell them that “something doesn’t work and I don’t understand why, please help me”.

–outside the scene functions

local music = audio.loadStream(“Automation.mp3”)

local mute

local unmute

–inside the function scene:show( event ), phase == will

mute = display.newImageRect(“Music 4.png”, aCW/5, aCW/5)

mute.x = cW - (cX/3)

mute.y = cSY + cY/8

unmute = display.newImageRect(“Music cancel 4.png”, aCW/6, aCW/6)

unmute.x = cW - (cX/3)

unmute.y = cSY + cY/8

unmute.isVisible = false

–inside the function scene:show( event ), phase == did

    local function muteSound()

      audio.pause(music)

      mute.isVisible = false

      unmute.isVisible = true

    end

    local function unMuteSound()

      audio.resume(music)

      mute.isVisible = true

      unmute.isVisible = false

    end

    mute:addEventListener(“tap”, muteSound)

    unmute:addEventListener(“tap”, unMuteSound)

Well, that’s still not much code to go by. All you do is create two buttons and add functions for turning the sounds on or off. But since neither function is actually ever used, I don’t know what happens. Do you leave them there and touch them by accident at approx. 1min mark? No idea.

I would recommend that you read roaminggamer’s post at https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/.

Also, please insert code by using the <> button to make it easier to read.

Well, the solution might be very simple. If you have the following code in your app, then just remove it.
 

local function stopAudio() audio.stop( backgroundMusicChannel ) end timer.performWithDelay( 60000+math.random(-5000,5000), stopAudio )

If you don’t happen to have this exact, or very similar piece of code in your app, then please share enough of your code, as well as the audio file, to replicate that issue so that others may try to help you. Sharing a sample project with the issue, zipping it and uploading it here would be the easiest method of getting help.

I’m sorry if I came across as a jerk, but you cannot realistically expect others to be able to help you if you only tell them that “something doesn’t work and I don’t understand why, please help me”.

–outside the scene functions

local music = audio.loadStream(“Automation.mp3”)

local mute

local unmute

–inside the function scene:show( event ), phase == will

mute = display.newImageRect(“Music 4.png”, aCW/5, aCW/5)

mute.x = cW - (cX/3)

mute.y = cSY + cY/8

unmute = display.newImageRect(“Music cancel 4.png”, aCW/6, aCW/6)

unmute.x = cW - (cX/3)

unmute.y = cSY + cY/8

unmute.isVisible = false

–inside the function scene:show( event ), phase == did

    local function muteSound()

      audio.pause(music)

      mute.isVisible = false

      unmute.isVisible = true

    end

    local function unMuteSound()

      audio.resume(music)

      mute.isVisible = true

      unmute.isVisible = false

    end

    mute:addEventListener(“tap”, muteSound)

    unmute:addEventListener(“tap”, unMuteSound)

Well, that’s still not much code to go by. All you do is create two buttons and add functions for turning the sounds on or off. But since neither function is actually ever used, I don’t know what happens. Do you leave them there and touch them by accident at approx. 1min mark? No idea.

I would recommend that you read roaminggamer’s post at https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/.

Also, please insert code by using the <> button to make it easier to read.