StreamingKit
StreamingKit copied to clipboard
Stop in seconds of the end of the track.
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 )
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.
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.
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.
@ccwendy33 let us know if the suggestions you've received fixes your issue
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.