teodorpatras / Jukebox

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

How to handle interruptions (e.g. phone calls)? #21

Closed sneps85 closed 8 years ago

sneps85 commented 8 years ago

Jukebox is a nice player, but when a phone call comes in, the player stops playing (as it should), but when the call ends, the player does not regain audio control...

teodorpatras commented 8 years ago

Thanks for pointing this thing out! Will investigate and then come back to you.

ankittlp commented 8 years ago

Is there is any update for this issue.

Thanks for the demo.

buddax2 commented 8 years ago

I fixed that in my fork and created a pull request

RajChanchal commented 7 years ago

@buddax2 The pull request you submitted has still a problem. For example a song is paused now, and an interruption occurs, after the interruption is ended, paused song starts playing!! I can suggest 2 solutions:

  1. Keep a previous player state: paused, palying and when interuption ends, restore player to same state
  2. when pausing or stopping the song, remove observers and when playing, add them again.
SergeHaddad commented 7 years ago

@RajChanchal can you elaborate more on those 2 solutions ? I have the same problem: when a song is paused and an interruption occurs, the song plays again. I didn't understand what should I do. Thanks in advance

RajChanchal commented 7 years ago

@SergeHaddad , I have used the first solution of mine i.e by introducing a previous state variable: self.previous_state. You can use my code: https://github.com/RajChanchal/Jukebox

Just write the following in your podfile to use my code: pod 'Jukebox' , :git => 'https://github.com/RajChanchal/Jukebox.git', :branch => 'master'