StreamingKit icon indicating copy to clipboard operation
StreamingKit copied to clipboard

Stop in seconds of the end of the track.

Open ccwendy33 opened this issue 6 years ago • 5 comments

I have a list of many tracks (url) . It always stops in seconds of the end of the track , maybe two or three seconds. I have figured out that didFinishPlayingQueueItemId function didn't get the STKAudioPlayerStopReason for STKAudioPlayerStopReason.eof. So I have no idea to set next track. please help me. ( wrote the app with Swift )

ccwendy33 avatar Mar 26 '19 06:03 ccwendy33

Make sure that you use the right delegate and that queue is set to no.

Sent from my iPhone

On Mar 25, 2019, at 11:58 PM, ccwendy33 [email protected] wrote:

I have a list of many tracks (url) . It always stops in seconds of the end of the track , maybe two or three seconds. I have figured out that didFinishPlayingQueueItemId function didn't get the STKAudioPlayerStopReason for STKAudioPlayerStopReason.eof. So I have no idea to set next track. please help me. ( wrote the app with Swift )

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

doriansgithub avatar Mar 26 '19 12:03 doriansgithub

Hello~ My code is below.

func audioPlayer(_ audioPlayer: STKAudioPlayer, didFinishPlayingQueueItemId queueItemId: NSObject, with stopReason: STKAudioPlayerStopReason, andProgress progress: Double, andDuration duration: Double) { 
        if stopReason == STKAudioPlayerStopReason.eof{
            print("[STK][didFinishPlaying]")
            m_isPrepared = false
            SMusicPlayerService.shareRenderer.onFinish()
        }
    }

Thank your for commenting.

ccwendy33 avatar Mar 27 '19 08:03 ccwendy33

When didFinishPlayingQueueItemId is fired, the song has finished playing, do not prepare next song here.

In didFinishBufferingSourceWithQueueItemId, prepare and queue - SKStreamingPlayer -(void) queueURL:(NSURL*)url - the next song to play. The rest is managed by StreamingKit.

iDevelopper avatar Mar 27 '19 08:03 iDevelopper

@ccwendy33 let us know if the suggestions you've received fixes your issue

diegostamigni avatar Mar 27 '19 17:03 diegostamigni

Hi all: First of all, many thanks for commenting.

The didFinishBufferingSourceWithQueueItemId is below

func audioPlayer(_ audioPlayer: STKAudioPlayer, didFinishBufferingSourceWithQueueItemId queueItemId: NSObject) {
        print("[STK][didFinishBufferingSourceWithQueueItemId]")
    }

I only print the log to show me if it is finished buffering in that delegate. I found out that this problem will occur when my app is on the background mode and it has played about three tracks and stop at the last second of the fourth track. When it enters foreground , it will start playing immediately. I'm sure that the background mode is set correctly.

ccwendy33 avatar Mar 28 '19 03:03 ccwendy33