Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

it takes time adding http extensions to jukebox player #81

Open
firatyenidunya opened this issue Aug 5, 2017 · 4 comments
Open

it takes time adding http extensions to jukebox player #81

firatyenidunya opened this issue Aug 5, 2017 · 4 comments

Comments

@firatyenidunya
Copy link

I am getting mp3 files from server. And there is al lot of mp3 files that are appended to jukebox player and it takes a lot of time. for example I am getting 25 music files I am adding them to jukebox player via for loop. It takes at least 20 seconds. Any suggestions? my code,

 for index in 0...self.musicInfo.count-1{
  JukeBoxManager.sharedInstance.jukebox.append(item: JukeboxItem (URL: URL(string: self.musicInfo[index].url)!), loadingAssets: true)
}
@RajChanchal
Copy link

It did also happen with me, what I did was, manage my own playlist array and keep track of next previous song. When one finishes, I start playing the next from my tracked playlist. Didn't get time to figure our why Jukebox is slow.

@firatyenidunya
Copy link
Author

How did you do that? Can you help me?

@RajChanchal
Copy link

Yes, sure. In my SongsPlayerViewController, I defined a property like:
private var playlist:Array<Song>!
Wrote a method in the same class as:
func playSongs(list:Array<Song>,indexToPlay:Int)
Whenever I need to play multiple songs, I just call this method. This method, in its definition, assigns the instance property playlist with list parameter of the method.
The definition of this method does also initialises Jukebox instance with only song item (selects the one based on indexToPlay from the list array) and calls Jukebox's play method.

When the progress of the current song reaches 1, you can call the same playSongs method with next song index and same playlist array.

if(currentSongIndex<playlist.count-1){
     currentSongIndex += 1
     _=self.playList(list: playlist, indexToPlay: currentSongIndex,playingNewPlaylist:false)
}

Let me know if you feel difficulty somewhere. I am using Jukebox's delegate method: jukeboxPlaybackProgressDidChange(_ jukebox : Jukebox) to track progress. jukeboxDidLoadItem( is not handy for playing the next song, I had to use progress method.

@firatyenidunya
Copy link
Author

I'll try. Thanks a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants