teodorpatras / Jukebox

Player for streaming local and remote audio files. Written in Swift.
MIT License
551 stars 122 forks source link

How can I use this as a singleton instance? #16

Closed alexliubj closed 8 years ago

alexliubj commented 8 years ago

How can I know my music is playing as a background music in my application? For e.g, I push from page 1 to page 2 which is my details page. I popup the music player in page2 and then play a sound (sound A). When I pop back to page 1, I still want my music is playing. When I come back to page 2 from page 1 again, I click the popup button for music player, I want it showing the current sound I was playing and show the status like 50% whatever (still sound A) but not init a new music player.

Please advise, it sounds like use this music player as a global singleton instance but I don't know how to implement it.

Thanks,

teodorpatras commented 8 years ago

You can inherit from Jukebox and make it singleton.

KushThakkar commented 8 years ago

Same Issue any one can Help. Create Singleton but I can't.

ghost commented 7 years ago

I am waiting the solution here. Let me know if any has been able to create singleton for this.

firatyenidunya commented 7 years ago

I solved this problem using code below,

import Jukebox
class JukeBoxManager{

    static let sharedInstance = JukeBoxManager()
    var jukebox : Jukebox!
    init(){

    }
}
ghost commented 7 years ago

@firatyenidunya I am very new to Swift. Would you please provide some example the its usages?