StreetVoice / HysteriaPlayer

Objective-C audio player, sitting on top of AVPlayer
Other
583 stars 99 forks source link

Player resumes when paused during buffering #112

Closed davros1970 closed 8 years ago

davros1970 commented 8 years ago

When I invoke pause() during the first few seconds of playing a mp3 from the internet, the player will resume unexpectedly. "HysteriaPlayer: resume from buffering.." If I wait 10 secs approx into the audio playing, then my calls to pause() are honored.

saiday commented 8 years ago

Can this issue reproduce on sample project?

davros1970 notifications@github.com 於 2016年3月16日星期三 寫道:

When I invoke pause() during the first few seconds of playing a mp3 from the internet, the player will resume unexpectedly. "HysteriaPlayer: resume from buffering.." If I wait 10 secs approx into the audio playing, then my calls to pause() are honored.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/StreetVoice/HysteriaPlayer/issues/112

davros1970 commented 8 years ago

Yes.

I modified the sample code like this... HysteriaPlayerSwiftExample.ViewController.swift

    func hysteriaPlayerReadyToPlay(identifier: HysteriaPlayerReadyToPlay) {
        switch(identifier) {
            case .CurrentItem:
                hysteriaPlayer.play()
                delay()
                break
            default:
                break
        }
    }

    func delay() {
        NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("pause"), userInfo: nil, repeats: false)
    }

    func pause() {
        print("Attempting to pause audio")
        hysteriaPlayer.pause()
    }

Then the logs look like this...

2016-03-16 07:20:46.835 HysteriaPlayerSwiftExample[17763:209724] unable to register background playback Attempting to pause audio 2016-03-16 07:20:48.943 HysteriaPlayerSwiftExample[17763:209724] resume from buffering..