iphone - How to add AVQueuePlayer in subview to show view -


i make avqueueplayer , add video items . when run app , video's sound play video not showing. know reason why video not showing , because haven't know how add avqueueplayer in view. please me

nsstring *firstvideopath = [[nsbundle mainbundle]                                        pathforresource:@"3" oftype:@"m4v"]; nsstring *secondvideopath = [[nsbundle mainbundle]                                      pathforresource:@"2" oftype:@"m4v"]; nsstring *thirdvideopath = [[nsbundle mainbundle]                                      pathforresource:@"3" oftype:@"m4v"];   avplayeritem *firstvideoitem = [avplayeritem playeritemwithurl:   [nsurl fileurlwithpath:firstvideopath]];     avplayeritem *secondvideoitem = [avplayeritem playeritemwithurl:                                                  [nsurl fileurlwithpath:secondvideopath]];     avplayeritem *thirdvideoitem = [avplayeritem playeritemwithurl:                                                 [nsurl fileurlwithpath:thirdvideopath]];      self.queueplayer = [avqueueplayer queueplayerwithitems:                         [nsarray arraywithobjects:firstvideoitem,                          secondvideoitem,thirdvideoitem,nil]];     [self.playerview setplayer:self.queueplayer];      [self.queueplayer play];    

first, grap paths:

nsstring *firstvideopath = [[nsbundle mainbundle] pathforresource:@"sample" oftype:@"m4v"]; nsstring *secondvideopath = [[nsbundle mainbundle] pathforresource:@"demo" oftype:@"mp4"]; nsstring *thirdvideopath = [[nsbundle mainbundle] pathforresource:@"3" oftype:@"m4v"];  avplayeritem *firstvideoitem = [avplayeritem playeritemwithurl:[nsurl fileurlwithpath:firstvideopath]]; avplayeritem *secondvideoitem = [avplayeritem playeritemwithurl:[nsurl fileurlwithpath:secondvideopath]]; avplayeritem *thirdvideoitem = [avplayeritem playeritemwithurl:[nsurl fileurlwithpath:thirdvideopath]]; 

init avqueueplayer:

avqueueplayer *queueplayer = [avqueueplayer queueplayerwithitems:@[firstvideoitem, secondvideoitem,thirdvideoitem]]; 

and use layer display movies playlist.

avplayerlayer *layer = [avplayerlayer layer];  [layer setplayer:queueplayer]; [layer setframe:cgrectmake(10, 10, 300, 200)]; [layer setbackgroundcolor:[uicolor redcolor].cgcolor]; [layer setvideogravity:avlayervideogravityresizeaspectfill];  [self.view.layer addsublayer:layer];  [queueplayer play]; 

don't forget add frameworks:

#import <quartzcore/quartzcore.h> #import "avfoundation/avfoundation.h" 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -