How to show video obtained from a http request in Android and iOS? -
here got url. can't provide whole string part of "http://*/video.mjpg". when open browser(firefox), shows video. when analyze package using fiddler, shows this:
http/1.1 200 ok
server:*
pragma:no-cache
cache-control:no-cache
content-type:multipart/x-mixed-replace; boundary="myboundary"
i search internet , got these key word: mime, dynamic parsing. still don't have clue how parse it. hope me. how parse message in java , objective-c display video content in android , ios?
for ios can use
edit
nsstring *url = @"http://*/video.mjpg"; nserror *error = nil; videodata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:url] options:nil error:&error]; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"videotoplay.mp4"]; [videodata writetofile:path atomically:yes]; nsurl *moveurl = [nsurl fileurlwithpath:path]; player = [[mpmovieplayercontroller alloc]init]; [player setcontenturl:moveurl]; player.view.frame = viewplayer.bounds; [viewplayer addsubview:player.view]; [player play]; have @ sample apple
for android
i not android developer had used answer demo tested.
Comments
Post a Comment