ios - Chrome Cast won't play served video -
okay i'm developing app chrome cast on ios. 1 of functions app perform play local videos device. i'm using external source found on github called cocoahttpserver. http server allows me upload files localhost service. use following code start server:
- (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. // configure our logging framework. // keep things simple , fast, we're going log xcode console. [ddlog addlogger:[ddttylogger sharedinstance]]; // create server using our custom myhttpserver class httpserver = [[httpserver alloc] init]; // tell server broadcast presence via bonjour. // allows browsers such safari automatically discover our service. [httpserver settype:@"_http._tcp."]; // there's no need run our server on specific port. // technologies bonjour allow clients dynamically discover server's port @ runtime. // however, easy testing may want force port can hit refresh button. // [httpserver setport:12345]; // serve files our embedded web folder nsstring *webpath = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"web"]; ddloginfo(@"setting document root: %@", webpath); [httpserver setdocumentroot:webpath]; [self startserver]; gblvb = [globalvariables singleobj]; self.mediacontrolchannel = [[gckmediacontrolchannel alloc] init]; self.mediacontrolchannel.delegate = self; [gblvb.devicemanager addchannel:self.mediacontrolchannel]; [self.mediacontrolchannel requeststatus]; }
this code sets http server , points in web folder imported main bundle , contains test video download google testing purposes(this video google use in sample of streaming chrome cast through web). got video http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/bigbuckbunny.mp4. code sets new media channel ready chrome cast cast to...
next have void function startserver
establishes connection , publishes server...
- (void)startserver { // start server (and check problems) nserror *error; if([httpserver start:&error]) { ddloginfo(@"started http server on port %hu", [httpserver listeningport]); } else { ddlogerror(@"error starting http server: %@", error); } }
lastly code bellow sets path equal localhost url , acctuallly cast video chrome cast:
-(void)viewdidappear:(bool)animated { path = [nsstring stringwithformat:@"localhost:%hu%@%@", [httpserver listeningport], @"/", @"bigbuckbunny.mp4"]; // additional setup after loading view nib. gblvb = [ globalvariables singleobj]; devicescanner = [[gckdevicescanner alloc] init]; [devicescanner addlistener:self]; [devicescanner startscan]; nsstring *image; nsstring *type; gckmediametadata *metadata = [[gckmediametadata alloc] init]; image = @"folder-video-icon.png"; [metadata setstring:@"the mp4 file format defined extensions on iso base media file format support mpeg-4 visual/audio codecs , various mpeg-4 systems features such object descriptors , scene descriptions." forkey:kgckmetadatakeysubtitle]; type = @"video/mp4"; [metadata setstring:[nsstring stringwithformat:@"%@%@", @"casting " , gblvb.filetype]forkey:kgckmetadatakeytitle]; [metadata addimage:[[gckimage alloc] initwithurl:[[nsurl alloc] initwithstring:image] width:480 height:360]]; //define media information sleep(2); gckmediainformation *mediainformation = [[gckmediainformation alloc] initwithcontentid:path streamtype:gckmediastreamtypenone contenttype:type metadata:metadata streamduration:0 customdata:nil]; //cast video [_mediacontrolchannel loadmedia:mediainformation autoplay:true playposition:0]; nslog(@"full path : %@", path); }
now problem when http server published , ready cast chrome cast not play though when navigate path on safari video displays perfectly. know chrome cast streams fine due fact streams googles online example video fine.
edit here debugging log form chrome cast:
failed load resource: server responded status of 404 (not found) https://www.gstatic.com/eureka/player/undefined [ 0.259s] [goog.net.websocket] opening websocket on ws://localhost:8008/v2/ipc cast_receiver.js:18 [ 0.580s] [goog.net.websocket] websocket opened on ws://localhost:8008/v2/ipc cast_receiver.js:18 https://www.gstatic.com/eureka/player/folder-video-icon.png 404 (not found) player.js:31 page @ 'https://www.gstatic.com/eureka/player/player.html?skin' loaded on https, displayed insecure content 'http://localhost:49598/bigbuckbunny.mp4': content should loaded on https. cast_receiver.js:69 http://localhost:49598/bigbuckbunny.mp4 cast_receiver.js:69 [ 21.834s] [cast.receiver.mediamanager] load metadata error cast_receiver.js:18 https://www.gstatic.com/eureka/player/folder-video-icon.png 404 (not found)
any appreciated.
i worked out instead of testing localhost on simulator write function current devices ip address , localhost part within line path = [nsstring stringwithformat:@"localhost:%hu%@%@", [httpserver listeningport], @"/", @"bigbuckbunny.mp4"];
replace devices ip address.
Comments
Post a Comment