muhku / FreeStreamer

A low-memory footprint streaming audio player for iOS and OS X
http://muhku.github.io/FreeStreamer/
Other
2.11k stars 436 forks source link

Stop and then start playing an AVAudioPlayer from local file #174

Open matiasf9 opened 9 years ago

matiasf9 commented 9 years ago

When I stop a FSAudioStream with a stream url loaded ( [self.streamer stop] ) and then start immediately an AVAudioPlayer with a local file ( self.audioPlayer = [[AVAudioPlayer alloc] initWithData:soundData error:&error], [self.audioPlayer play]; ), the audioPlayer´s sound is stopped and the device throw me a warning ([0x384aa9dc] AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.)

This does not happen in the simulators, only in devices. In simulator, the code works perfect.

syrakozz commented 9 years ago

+1

matiasf9 commented 9 years ago

I fixed replacing all the lines related to AVAudioSession like:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; [[AVAudioSession sharedInstance] setActive:NO error:nil];

By a line like this: [[MyPlayer sharedInstance] setUpAudioSession];

And I manage the AudioSession correctly there by myself.

bbalachandhar commented 9 years ago

@matiasf9 i am also facing the same issue. could you tell me what should i do to solve this?

in your comment, what will do in "setUpAudioSession"?

humayunharoon commented 9 years ago

@matiasf9 same issue.. can you please post your fix?

bizibizi commented 6 years ago

+1

bizibizi commented 6 years ago

@muhku any news?

bizibizi commented 6 years ago

solved by:

        let configuration = FSStreamConfiguration()
        configuration.automaticAudioSessionHandlingEnabled = false
        audioPlayerMeditation = FSAudioStream(configuration: configuration)
        audioPlayerMeditation?.url = url as NSURL