From 46d99fcade3134c66d49af577bc3656e3008408b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 25 Feb 2015 21:49:45 +0100 Subject: [PATCH 1/9] Use the default video in the inline player demos --- XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m | 3 ++- XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m index 771263f0..fb6f5a37 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m @@ -25,7 +25,8 @@ - (IBAction) load:(id)sender { [self.videoContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"VpZmIiIXuZ0"]; + NSString *videoIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"VideoIdentifier"]; + self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:videoIdentifier]; self.videoPlayerViewController.moviePlayer.backgroundPlaybackEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"PlayVideoInBackground"]; [self.videoPlayerViewController presentInView:self.videoContainerView]; diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m index dad824f5..ae5b1249 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m @@ -14,7 +14,8 @@ @implementation DemoThumbnailViewController - (IBAction) loadThumbnail:(id)sender { - self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"VpZmIiIXuZ0"]; + NSString *videoIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"VideoIdentifier"]; + self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:videoIdentifier]; self.videoPlayerViewController.moviePlayer.backgroundPlaybackEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"PlayVideoInBackground"]; NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; From affaefc67e75c441f49f00e48c63684571357955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 25 Feb 2015 21:59:24 +0100 Subject: [PATCH 2/9] Add now playing URL log --- XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m index 9757d058..f98b47c4 100644 --- a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m +++ b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m @@ -30,6 +30,7 @@ - (void) setEnabled:(BOOL)enabled [defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; [defaultCenter addObserver:self selector:@selector(moviePlayerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; + [defaultCenter addObserver:self selector:@selector(moviePlayerNowPlayingMovieDidChange:) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil]; } else { @@ -37,6 +38,7 @@ - (void) setEnabled:(BOOL)enabled [defaultCenter removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [defaultCenter removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; [defaultCenter removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; + [defaultCenter removeObserver:self name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil]; } } @@ -104,6 +106,12 @@ - (void) moviePlayerLoadStateDidChange:(NSNotification *)notification NSLog(@"Load State: %@", loadState.length > 0 ? [loadState substringFromIndex:3] : @"N/A"); } +- (void) moviePlayerNowPlayingMovieDidChange:(NSNotification *)notification +{ + MPMoviePlayerController *moviePlayerController = notification.object; + NSLog(@"Now Playing %@", moviePlayerController.contentURL); +} + - (void) videoPlayerViewControllerDidReceiveVideo:(NSNotification *)notification { NSLog(@"Video: %@", notification.userInfo[XCDYouTubeVideoUserInfoKey]); From 829e14a4bc7db2170f92e6325d8e0a439031fc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 13 Mar 2015 17:21:29 +0100 Subject: [PATCH 3/9] Fix playback of some protected videos Get the `sts` value from the web page if not available from the embed web page. Fixes #122 --- CHANGELOG.md | 4 + .../testProtectedVEVOIsPlayable.json | 113 ++++++++++++++++++ .../XCDYouTubeProtectedVideosTestCase.m | 24 ++++ XCDYouTubeKit/XCDYouTubeVideoOperation.m | 2 +- 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 XCDYouTubeKit Tests/Cassettes/XCDYouTubeProtectedVideosTestCase/testProtectedVEVOIsPlayable.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cd58a3e..d9d54cfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### Version 2.1.2 + +* Fixed playback of some protected videos. (#122) + #### Version 2.1.1 * Adaptation to YouTube API change. (#116) diff --git a/XCDYouTubeKit Tests/Cassettes/XCDYouTubeProtectedVideosTestCase/testProtectedVEVOIsPlayable.json b/XCDYouTubeKit Tests/Cassettes/XCDYouTubeProtectedVideosTestCase/testProtectedVEVOIsPlayable.json new file mode 100644 index 00000000..081abf0c --- /dev/null +++ b/XCDYouTubeKit Tests/Cassettes/XCDYouTubeProtectedVideosTestCase/testProtectedVEVOIsPlayable.json @@ -0,0 +1,113 @@ +[ + { + "body" : "