StreetVoice / HysteriaPlayer

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

Unable to play a shoutcast stream #57

Open thierryb opened 10 years ago

thierryb commented 10 years ago

Hi,

I am unable to play a shoutcast stream like goovesalad from somaFM.

http://ice.somafm.com/groovesalad

AVPlayer ask only for 1 byte then connection is stopped.

Do you have an idea?

Thanks

hamzaozturk commented 9 years ago

Hi thierryb,

It is a bug related to AVPlayer. If you first initialize an AVPlayer with a local file, then you can not play any shoutcast stream.

If you check HysteriaPlayer.m file, there is a method called playEmptySound. It initializes AVPlayer with a local file. If you change the method as below, then you can play any streaming content. But, at this time, you can not play any local media.

- (void)playEmptySound { self.isInEmptySound = YES; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://ice.somafm.com/groovesalad"]]; self.audioPlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObject:playerItem]]; }

saiday commented 9 years ago

This is interesting, could you provide more shoutcast streams? Would like to test it out.

hamzaozturk notifications@github.com 於 2015年5月21日 星期四寫道:

Hi thierryb,

It is a bug related to AVPlayer. If you first initialize an AVPlayer with a local file, then you can not play any shoutcast stream.

If you check HysteriaPlayer.m file, there is a method called playEmptySound. It initializes AVPlayer with a local file. If you change the method as below, then you can play any streaming content. But, at this time, you can not play any local media.

  • (void)playEmptySound { self.isInEmptySound = YES; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@" http://ice.somafm.com/groovesalad"]]; self.audioPlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObject:playerItem]]; }

— Reply to this email directly or view it on GitHub https://github.com/StreetVoice/HysteriaPlayer/issues/57#issuecomment-103970154 .

hamzaozturk commented 9 years ago

You can find here: http://stackoverflow.com/questions/10104301/hls-streaming-video-url-need-for-testing

I have solved this problem as explained below:

If there is a transition from streaming content to local file or vice versa, I initialize the AVPlayer object again with the selected choice(local or remote).

hamzaozturk commented 8 years ago

It still can not play the mixture of streaming and file-based media. If you think it is the solution what changed on ios9, it does not support for ios7 and ios8.

Ref: iOS 9 release note

AVQueuePlayer now supports a mixture of file-based media and HTTP Live Streaming media in its queue. Prior to this, you had to ensure that all items in the queue were of the same type.

saiday commented 8 years ago

Yes, I knew this AVQueuePlayer behaviour changed since iOS 9. Sure, HysteriaPlayer had the chances to know the type of each input source, can initial new AVQueuePlayer when needs. I thought this implementation wouldn't change HysteriaPlayer API, and it's easier to use.

Thanks for your wise counsel. Reopen this issue. Currently all my apps had no mixture of HTTP Live streaming and file-based media queue. I have no plans to support this feature in the primary now.

saiday commented 8 years ago

There's a workaround if someone going to play HTTP Live Streaming, set skipEmptySoundPlaying to true before playing.

tarzon commented 8 years ago

Hi @saiday, I am facing the same issue. I am also unable to play mixture of local and streaming URLs. If I start playing with local urls, then it would play the local files, and then If I switch to stream URL, it would play it, but second time when I switch to local file Url, it would not play it. And then again if I roll back to stream URL, it wont play it either. This behaviour is permanent. Any help would be great.

saiday commented 8 years ago

@tarzon like what @hamzaozturk mentioned

AVQueuePlayer now supports a mixture of file-based media and HTTP Live Streaming media in its queue. Prior to this, you had to ensure that all items in the queue were of the same type

from iOS 9 release note: https://developer.apple.com/library/prerelease/content/releasenotes/General/RN-iOSSDK-9.0/index.html

The best way to get rid of it is check audio resource type before player start playing, if you're going to play another type from previous resource, deprecate HysteriaPlayer by deprecatePlayer() and you will get a new instance next time you call HysteriaPlayer.sharedInstance().

tarzon commented 8 years ago

@saiday Thankyou. It worked.