Ios9 / swift2 / xcode7 + AVplayer icecast does not handle streaming without a file extension

how will you play the stream from icecast2, which does not have a file extension

example stream url: http: // icecast: 8044 / channel-123? a = hash

format: mp4a

the code seems to work with files with the extension, but not with files without.

var player = AVPlayer(); let playerItem = AVPlayerItem(URL:NSURL(string:"http://host/file.mp4a")!); player = AVPlayer(playerItem:playerItem) let playerController = AVPlayerViewController() playerController.view.frame = self.view.frame playerController.player = player self.addChildViewController(playerController) self.view.addSubview(playerController.view) player.play() 

EDIT: Basically, when the stream address ends without a file extension (the file on the server is stored without a file extension such as .mp3, .mp4, ..), AVPlayer will not play anything ( http://example.com/file ). .. but if the file name contains the file extension, it works correctly ( http://example.com/file.mp3 )

+6
source share
1 answer

It seems that you are confusing streaming and downloading media files from the server.

If we talk about live stream:

1) The file extension does not affect the ability of the AVPlayer player (AVPlayer plays audio from this link, for example: http://icecast.omroep.nl/radio1-bb-aac ).

2) However, the file format does matter (for more information check the docs here ):

What are the features of the supported video and audio formats?

Although the protocol specification does not limit video and audio formats, the current Apple implementation supports the following formats:

Video: H.264 3.0 basic level, 3.1 basic level, 3.1 basic level and 4.1 high profile level. Audio: HE-AAC or AAC-LC up to 48 kHz, stereo MP3 audio (MPEG-1 Audio Layer 3) from 8 kHz to 48 kHz, stereo audio AC-3 (for Apple TV in pass-through mode only)

If you have your own server and want to provide the ability to stream audio / video, you need to perform some configuration steps, as described here .

0
source

All Articles