Merge pull request #11465 from WenhaiLin/v3-videoplayer-iosfix

Fix crash when play streamed MP4 file.
This commit is contained in:
minggo 2015-04-16 18:16:28 +08:00
commit 3c7d5afce2
2 changed files with 3 additions and 2 deletions

View File

@ -134,8 +134,9 @@ using namespace cocos2d::experimental::ui;
} }
if (videoSource == 1) { if (videoSource == 1) {
self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@(videoUrl.c_str())]] autorelease]; self.moviePlayer = [[[MPMoviePlayerController alloc] init] autorelease];
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.moviePlayer setContentURL:[NSURL URLWithString:@(videoUrl.c_str())]];
} else { } else {
NSString *path = [UIVideoViewWrapperIos fullPathFromRelativePath:@(videoUrl.c_str())]; NSString *path = [UIVideoViewWrapperIos fullPathFromRelativePath:@(videoUrl.c_str())];
self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] autorelease]; self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] autorelease];

View File

@ -104,7 +104,7 @@ void VideoPlayerTest::menuOnlineVideoCallback(Ref* sender)
{ {
if (_videoPlayer) if (_videoPlayer)
{ {
_videoPlayer->setURL("http://video001.smgbb.cn/gslb/program/FDN/FDN1190949/HLSVodService.m3u8?_mdCode=6065719&_cdnCode=B2B_XL_TEST&_type=0&_rCode=TerOut_18865&_userId=020341000456068&_categoryCode=SMG_HUAYU&_categoryPath=SMG_1002,SMG_HUAYU,&_adPositionId=01001000&_adCategorySource=0&_flag=.m3u8&_enCode=m3u8&taskID=ysh_ps_002-ott_1397459105893_020341000456068&_client=103&_cms=ctv&_CDNToken=76C043FD4969501754DC19E54EC8DC2C"); _videoPlayer->setURL("http://benchmark.cocos2d-x.org/cocosvideo.mp4");
_videoPlayer->play(); _videoPlayer->play();
} }
} }