diff --git a/Demo/Vitamio-Demo.xcodeproj/project.pbxproj b/Demo/Vitamio-Demo.xcodeproj/project.pbxproj index 9bdd3f6..5293445 100644 --- a/Demo/Vitamio-Demo.xcodeproj/project.pbxproj +++ b/Demo/Vitamio-Demo.xcodeproj/project.pbxproj @@ -398,6 +398,7 @@ "../../ios-vitamio/build/Release-iphoneos", ../Vitamio, ); + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-all_load"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Demo/Vitamio-Demo/PlayerController.m b/Demo/Vitamio-Demo/PlayerController.m index 5957a10..d9664e0 100644 --- a/Demo/Vitamio-Demo/PlayerController.m +++ b/Demo/Vitamio-Demo/PlayerController.m @@ -22,7 +22,7 @@ @interface PlayerController () @property (nonatomic, assign) IBOutlet UIButton *prevBtn; @property (nonatomic, assign) IBOutlet UIButton *nextBtn; @property (nonatomic, assign) IBOutlet UIButton *modeBtn; -@property (nonatomic, assign) IBOutlet UIButton *restartBtn; +@property (nonatomic, assign) IBOutlet UIButton *reset; @property (nonatomic, assign) IBOutlet UISlider *progressSld; @property (nonatomic, assign) IBOutlet UILabel *curPosLbl; @property (nonatomic, assign) IBOutlet UILabel *durationLbl; @@ -53,16 +53,28 @@ - (void)viewDidLoad if (!mMPayer) { mMPayer = [VMediaPlayer sharedInstance]; [mMPayer setupPlayerWithCarrierView:self.view withDelegate:self]; + [self setupObservers]; } } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + [[UIApplication sharedApplication] setStatusBarHidden:YES]; + [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; + [self becomeFirstResponder]; [self currButtonAction:nil]; } +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + [[UIApplication sharedApplication] setStatusBarHidden:NO]; + [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; + [self resignFirstResponder]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -70,6 +82,7 @@ - (void)didReceiveMemoryWarning - (void)dealloc { + [self unSetupObservers]; [_videoURL release]; [_activityView release]; [mMPayer unSetupPlayer]; @@ -93,6 +106,57 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface } +#pragma mark - Respond to the Remote Control Events + +- (BOOL)canBecomeFirstResponder +{ + return YES; +} + +- (void)remoteControlReceivedWithEvent:(UIEvent *)event +{ + switch (event.subtype) { + case UIEventSubtypeRemoteControlTogglePlayPause: + if ([mMPayer isPlaying]) { + [mMPayer pause]; + } else { + [mMPayer start]; + } + break; + case UIEventSubtypeRemoteControlPlay: + [mMPayer start]; + break; + case UIEventSubtypeRemoteControlPause: + [mMPayer pause]; + break; + case UIEventSubtypeRemoteControlPreviousTrack: + [self prevButtonAction:nil]; + break; + case UIEventSubtypeRemoteControlNextTrack: + [self nextButtonAction:nil]; + break; + default: + break; + } +} + +- (void)applicationDidEnterForeground:(NSNotification *)notification +{ + if (![mMPayer isPlaying]) { + [mMPayer start]; + [self.startPause setTitle:@"Pause" forState:UIControlStateNormal]; + } + [mMPayer setVideoShown:YES]; +} + +- (void)applicationDidEnterBackground:(NSNotification *)notification +{ + if ([mMPayer isPlaying]) { + [mMPayer setVideoShown:NO]; + } +} + + #pragma mark - VMediaPlayerDelegate Implement #pragma mark VMediaPlayerDelegate Implement / Required @@ -137,8 +201,8 @@ - (void)mediaPlayer:(VMediaPlayer *)player setupPlayerPreference:(id)arg { // Set buffer size, default is 1024KB(1*1024*1024). // [player setBufferSize:2*1024*1024]; - [player setBufferSize:512*1024]; - [player setAdaptiveStream:YES]; + [player setBufferSize:12*1024]; +// [player setAdaptiveStream:YES]; } - (void)mediaPlayer:(VMediaPlayer *)player bufferingStart:(id)arg @@ -179,14 +243,57 @@ - (void)mediaPlayer:(VMediaPlayer *)player downloadRate:(id)arg #pragma mark - Convention Methods +#define TEST_Common 1 +#define TEST_setOptionsWithKeys 0 +#define TEST_setDataSegmentsSource 0 + -(void)quicklyPlayMovie:(NSURL*)fileURL title:(NSString*)title seekToPos:(long)pos { [UIApplication sharedApplication].idleTimerDisabled = YES; - [[UIApplication sharedApplication] setStatusBarHidden:YES]; - - self.videoURL = fileURL; [self setBtnEnableStatus:NO]; + +#if TEST_Common // Test Common + NSString *abs = [fileURL absoluteString]; + if ([abs rangeOfString:@"://"].length == 0) { + NSString *docDir = [NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]; + NSString *videoUrl = [NSString stringWithFormat:@"%@/%@", docDir, abs]; + self.videoURL = [NSURL fileURLWithPath:videoUrl]; + } else { + self.videoURL = fileURL; + } [mMPayer setDataSource:self.videoURL header:nil]; +#elif TEST_setOptionsWithKeys // Test setOptionsWithKeys:withValues: + self.videoURL = [NSURL URLWithString:@"rtmp://videodownls.9xiu.com/9xiu/552"]; // This is a live stream. + NSMutableArray *keys = [NSMutableArray arrayWithCapacity:0]; + NSMutableArray *vals = [NSMutableArray arrayWithCapacity:0]; + keys[0] = @"-rtmp_live"; + vals[0] = @"-1"; + [mMPayer setDataSource:self.videoURL header:nil]; + [mMPayer setOptionsWithKeys:keys withValues:vals]; +#elif TEST_setDataSegmentsSource // Test setDataSegmentsSource:fileList: + NSMutableArray *list = [NSMutableArray arrayWithCapacity:0]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.1.mp4?vkey=E3D97333E93EDF36E56CB85CE0B02018E1001BA5C023DFFD298C0204CD81610CFCE546C79DE6C3E2"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.2.mp4?vkey=5E82F44940C19CCF26610E7E4088438E868AB2CAB5255E5FDE6763484B9B7E967EF9A97D7E54A324"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.3.mp4?vkey=0A1EA30BCB057BAE8746C2D7B07FE4ABF3BD839FF011224F31F7544BFFB647F06A6D5245C57277BC"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.4.mp4?vkey=DF36DC29AD2C2F0BA5A688223AFCD0008BDD681D8B060C9F4739E1A365495CD165E28DFD80E8E41C"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.5.mp4?vkey=76172D18B89A91CDB803889B4C5127741EF4BBD9B90CC54269B89CEEF558B9B286DDE6083ADB8195"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.6.mp4?vkey=27718B68A396DCFBC483321827604179D35F31C41EC57908C0F78D9416690F6986B0766872C2AF60"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.7.mp4?vkey=B56628DD31A60E975CC9EE321DCE2FC9554AF2CE5BC2BFCEFCEEA633F27CDF16CADA9915338AB2E5"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.8.mp4?vkey=40F45871CE7827699FACE57A95CA1FDA58B16A8A2523C738C422ADCBF015F50254C356614EFAFDE0"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.9.mp4?vkey=553157FD5A7607CC1E255D0E26B503FAD842DC509F15D766C31446E8607E60A621F7B9FABC5B8C7D"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.10.mp4?vkey=2968D15E93D1C1A295FC810DA561789487330F8BEA5B408533BF396648400A89924611724FD5BE67"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.11.mp4?vkey=495CDFCAD30945947CE1E43CBD88DE32E505B4D02BD4AAB2F4B17F98EFF702485C270558951A3109"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.12.mp4?vkey=01B5580A0A6F3597D66440C060885AFC7AA03CD7272D36472FBC9C261D72D2E964D254775C574CA3"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.13.mp4?vkey=2256FFE5FABC971F6A0D6889A1EA1CE8E837D17929708C6ACC6F903939076BB926442DBF6F3AD309"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.14.mp4?vkey=77BB2C40B9383BF048206EC357FE5F061A0A16B9242CAD207CBEA3C3C53E50B24056D93E578A400F"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.15.mp4?vkey=1366F026BB6B987C82C58CF707269C091EA086BB1A09430611A6E124A419E04774FE793E11EB64C1"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.16.mp4?vkey=E0F358E64365C5B12614EA74B25C4F87C7E8CD4003DCB2C792850180CF3CD7645BB22E5E57B40CC5"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.17.mp4?vkey=E95EC62FAE0D92BE8A2FE85842B875F2E9B9B07616B8892D1EF18A0C645994E885D65BDAC24EF0FD"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.18.mp4?vkey=48B021C886CFC23E22FA56C71C7C204E300E7D58CBB97867F23CC8F30EB4D1B53ABE41627F7D6610"]; + [list addObject:@"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.19.mp4?vkey=0D51F428BB12C2C5C015E41997371FC80338924F804D9D688C7B9560C7336A48870873F34189C58D"]; + [mMPayer setDataSegmentsSource:nil fileList:list]; +#endif + [mMPayer prepareAsync]; [self startActivityWithMsg:@"Loading..."]; } @@ -200,12 +307,15 @@ -(void)quicklyReplayMovie:(NSURL*)fileURL title:(NSString*)title seekToPos:(long -(void)quicklyStopMovie { [mMPayer reset]; - [mSyncSeekTimer invalidate]; mSyncSeekTimer = nil; - + [self stopActivity]; + self.curPosLbl.text = @"00:00:00"; + self.durationLbl.text = @"00:00:00"; + self.downloadRate.text = nil; + self.progressSld.value = 0.0; + [self setBtnEnableStatus:YES]; [UIApplication sharedApplication].idleTimerDisabled = NO; - [[UIApplication sharedApplication] setStatusBarHidden:NO]; } @@ -290,9 +400,9 @@ -(IBAction)switchVideoViewModeButtonAction:(id)sender [mMPayer setVideoFillMode:modes[curModeIdx]]; } --(IBAction)restartButtonAction:(id)sender +-(IBAction)resetButtonAction:(id)sender { - [self quicklyReplayMovie:self.videoURL title:nil seekToPos:0]; + [self quicklyStopMovie]; } -(IBAction)dragProgressSliderAction:(id)sender @@ -335,9 +445,27 @@ -(void)setBtnEnableStatus:(BOOL)enable self.prevBtn.enabled = enable; self.nextBtn.enabled = enable; self.modeBtn.enabled = enable; - self.restartBtn.enabled = enable; } +- (void)setupObservers +{ + NSNotificationCenter *def = [NSNotificationCenter defaultCenter]; + [def addObserver:self + selector:@selector(applicationDidEnterForeground:) + name:UIApplicationDidBecomeActiveNotification + object:[UIApplication sharedApplication]]; + [def addObserver:self + selector:@selector(applicationDidEnterBackground:) + name:UIApplicationWillResignActiveNotification + object:[UIApplication sharedApplication]]; +} + +- (void)unSetupObservers +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + + -(void)showVideoLoadingError { NSString *sError = NSLocalizedString(@"Video cannot be played", @"description"); @@ -356,5 +484,4 @@ -(void)showVideoLoadingError [alertView release]; } - -@end +@end \ No newline at end of file diff --git a/Demo/Vitamio-Demo/PlayerController.xib b/Demo/Vitamio-Demo/PlayerController.xib index 9e04e11..804d36a 100644 --- a/Demo/Vitamio-Demo/PlayerController.xib +++ b/Demo/Vitamio-Demo/PlayerController.xib @@ -46,7 +46,6 @@ 293 {{49, 0}, {48, 44}} - _NS:9 NO @@ -59,6 +58,10 @@ 3 MQA + + 3 + MC42NjY2NjY2NjY3AA + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -82,7 +85,6 @@ 293 {{105, 0}, {48, 44}} - _NS:9 NO @@ -92,6 +94,7 @@ 1 Prev + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -105,7 +108,6 @@ 293 {{157, 0}, {48, 44}} - _NS:9 NO @@ -115,6 +117,7 @@ 1 Next + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -128,7 +131,6 @@ 292 {46, 44} - _NS:9 NO @@ -138,6 +140,7 @@ 1 Exit + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -151,7 +154,6 @@ 293 {{212, 0}, {44, 44}} - _NS:9 NO @@ -161,6 +163,7 @@ 1 Mode + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -172,9 +175,8 @@ 289 - {{260, 0}, {60, 44}} + {{258, 0}, {65, 44}} - _NS:9 NO @@ -182,8 +184,9 @@ 0 0 1 - Restart + Reset + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA @@ -197,7 +200,6 @@ 289 {{191, 60}, {129, 33}} - _NS:9 NO @@ -227,7 +229,6 @@ {320, 104} - _NS:9 @@ -245,7 +246,6 @@ 266 {{50, 48}, {217, 23}} - _NS:9 NO @@ -258,7 +258,6 @@ 268 {{4, 48}, {50, 21}} - _NS:9 NO @@ -292,7 +291,6 @@ 265 {{272, 48}, {50, 21}} - _NS:9 NO @@ -315,7 +313,6 @@ {{0, 390}, {320, 90}} - _NS:9 @@ -326,7 +323,6 @@ 301 {{33, 169}, {242, 92}} - _NS:9 NO @@ -360,7 +356,6 @@ 301 {{134, 116}, {40, 40}} - _NS:9 @@ -369,7 +364,6 @@ {320, 480} - 1 @@ -463,19 +457,19 @@ - restartBtn + downloadRate - + - 43 + 45 - downloadRate + reset - + - 45 + 46 @@ -515,12 +509,12 @@ - restartButtonAction: + resetButtonAction: 7 - 22 + 47 @@ -664,18 +658,23 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -683,98 +682,9 @@ - 45 - - - - - PlayerController - UIViewController - - id - id - id - - - - goBackButtonAction: - id - - - restartButtonAction: - id - - - switchVideoViewModeButtonAction: - id - - - - UIView - UILabel - UILabel - UILabel - UILabel - UIButton - UIButton - UIButton - UISlider - UIButton - UIButton - - - - activityCarrier - UIView - - - bubbleMsgLbl - UILabel - - - curPosLbl - UILabel - - - downloadRate - UILabel - - - durationLbl - UILabel - - - modeBtn - UIButton - - - nextBtn - UIButton - - - prevBtn - UIButton - - - progressSld - UISlider - - - restartBtn - UIButton - - - startPause - UIButton - - - - IBProjectSource - ./Classes/PlayerController.h - - - + 47 + 0 IBCocoaTouchFramework YES diff --git a/Demo/Vitamio-Demo/ViewController.m b/Demo/Vitamio-Demo/ViewController.m index eb15c7a..25315c2 100644 --- a/Demo/Vitamio-Demo/ViewController.m +++ b/Demo/Vitamio-Demo/ViewController.m @@ -11,7 +11,6 @@ #import "PlayerController.h" #import "PlayerControllerDelegate.h" - @interface ViewController () @end @@ -19,22 +18,23 @@ @interface ViewController () @implementation ViewController static NSString *sMediaURLs[] = { -// [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"video-demo.mkv"], // @"assets-library://asset/asset.MOV?id=112C86F5-1A5E-42EF-ADFA-0BE19C540665&ext=MOV", -// @"http://ndrstream.ic.llnwd.net/stream/ndrstream_ndr1wellenord_hi_mp3", -// @"http://112.197.2.11:1935/live/vtv3.stream/playlist.m3u8", - - @"http://184.72.239.149/vod/smil:bigbuckbunnyiphone.smil/playlist.m3u8", // contains multiple video stream @"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8", // contains multiple video stream + @"http://112.65.235.140/vlive.qqvideo.tc.qq.com/95V8NuxWX2J.p202.5.mp4?vkey=76172D18B89A91CDB803889B4C5127741EF4BBD9B90CC54269B89CEEF558B9B286DDE6083ADB8195", + @"mms://alive.rbc.cn/fm1006", + @"mms://218.61.6.228/jtgb?NiMwIzE=", + @"rtmp://113.161.212.25/live/atv1", + @"http://v.youku.com/player/getRealM3U8/vid/XNTk5NTgxODg0/type/flv/ts/1377694407/useKeyframe/0/video.m3u8", + @"http://ndrstream.ic.llnwd.net/stream/ndrstream_ndr1wellenord_hi_mp3", + @"http://112.197.2.11:1935/live/vtv3.stream/playlist.m3u8", + @"http://184.72.239.149/vod/smil:bigbuckbunnyiphone.smil/playlist.m3u8", // contains multiple video stream @"http://sjlive.cbg.cn/app_2/_definst_/ls_2.stream/playlist.m3u8", - @"http://meta.video.qiyi.com/242/de25dc2b5d385a8e27304d1e6dcd1a35.m3u8", - @"http://ipadlive.cntv.soooner.com/cctv_p2p_hdtaiqiu.m3u8", -// @"http://219.232.160.145:5080/livestream/esx7h676.ts", // can't loadind? @"mms://cdnmms.cnr.cn/cnr001", @"http://94.242.221.141/hls/a-lo/stream140.m3u8", - @"http://159.226.15.215:8080/hls/zeiou/zeiou.m3u8", + + @"video-demo.mkv", }; static int sCurrPlayIdx; diff --git a/Demo/Vitamio-Demo/Vitamio-Demo-Info.plist b/Demo/Vitamio-Demo/Vitamio-Demo-Info.plist index 81574d6..170c479 100644 --- a/Demo/Vitamio-Demo/Vitamio-Demo-Info.plist +++ b/Demo/Vitamio-Demo/Vitamio-Demo-Info.plist @@ -20,6 +20,10 @@ 1.0 CFBundleSignature ???? + UIBackgroundModes + + audio + CFBundleVersion 1.0 LSRequiresIPhoneOS diff --git a/Doc/com.yixia.Vitamio.docset/Contents/Resources/Documents/Classes/VMediaExtracter.html b/Doc/com.yixia.Vitamio.docset/Contents/Resources/Documents/Classes/VMediaExtracter.html index 5db18e0..e4c0da0 100644 --- a/Doc/com.yixia.Vitamio.docset/Contents/Resources/Documents/Classes/VMediaExtracter.html +++ b/Doc/com.yixia.Vitamio.docset/Contents/Resources/Documents/Classes/VMediaExtracter.html @@ -422,7 +422,7 @@

Declared In