ios - Using the AVURLAsset to play a Remote Video File -
i want use avurlasset play video file on server not local file. have read avurlasset cant used directly remote files . read link of stack overflow
avurlasset cannot load remote file
this link has method use avurlasset play remote files not able understand fully. observer not being called. can please me? don't want use avplayer play video reasons. grabbing frames avasset , rendering them textures in opengl need avurlasset only.
here code at
-(void) startplayer { nsurl *url=[nsurl fileurlwithpath:@"http://gamooz.com/wildlife.mp4"]; pitem = [avplayeritem playeritemwithurl:url]; player = [avplayer playerwithplayeritem:pitem]; [player play]; pitem addobserver:self forkeypath:@"status" options:0 context:nil]; } -(void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change: (nsdictionary *)change context:(void *)context { nslog(@"heyy"); if ([keypath isequaltostring:@"status"]) { avplayeritem *pitemtemp = (avplayeritem *)object; if (pitemtemp.status == avplayeritemstatusreadytoplay) { ///now can use playeritem asset asset = (avurlasset *)pitemtemp.asset; } } }
but observer never getting called. why that?
also put observer code in other function , tried check if playeritem ready play
-(void) checkforplayer { if (pitem.status == avplayeritemstatusreadytoplay) { asset = (avurlasset *)pitem.asset; } }
it never giving status equal ready.
Comments
Post a Comment