In my iOS application, I need to play video using external accessory framework. The framework will provide the stream over a delegate method. But i couldnot find a player which plays from byte stream. Please recommend the best way to approach this problem
- (void)stream:(NSStream*)theStream handleEvent:(NSStreamEvent)streamEvent { }
There are two approaches to this, the first one is to save the byte stream in an local temporal file and then play it with AVAsset.
If you don't want to save the video in the device you can make a HTTPServer within your app and use AVURLAsset to play it with AVPlayer. Here is a example using GCD Web Server, please notice that the server needs to accept ranges requests in order to work perfectly with AVPlayer and .
Then you can set your AVPlayer to consume the local web server to play the video.