Reputation: 79
how would you play a 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 be working on files with an extension, but not on 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 the file extension (the file on server is stored without any file extension like .mp3, .mp4,..) the AVPlayer will not play anything(http://example.com/file) ... but if the file name contains the file extension it works properly (http://example.com/file.mp3)
Upvotes: 7
Views: 629
Reputation: 7908
It seems that you are confusing live streaming and loading media files from server.
If we are talking about live streaming:
1) File extension has no impact on AVPlayer ability to play stream (AVPlayer plays audio from this link, for example: http://icecast.omroep.nl/radio1-bb-aac).
2) Nevertheless, file format is matter (for more information check docs here):
What are the specifics of the video and audio formats supported?
Although the protocol specification does not limit the video and audio formats, the current Apple implementation supports the following formats:
Video: H.264 Baseline Level 3.0, Baseline Level 3.1, Main Level 3.1, and High Profile Level 4.1. Audio: HE-AAC or AAC-LC up to 48 kHz, stereo audio MP3 (MPEG-1 Audio Layer 3) 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 ability to streaming audio/video, you need to perform some setup actions as described here.
Upvotes: 0