Created
March 30, 2014 23:56
-
-
Save ahonnecke/9882174 to your computer and use it in GitHub Desktop.
Adding try catch to MPMediaItemProperty load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 098a4ec62e973997ec7faba5a5435975652fb9a7 Mon Sep 17 00:00:00 2001 | |
From: Ashton Honnecke <ashton@pixelstub.com> | |
Date: Sun, 30 Mar 2014 17:54:05 -0600 | |
Subject: [PATCH] try catch around mpmediaplayer metadata | |
--- | |
GVMusicPlayerController/GVMusicPlayerController.m | 12 ++++++++++-- | |
1 file changed, 10 insertions(+), 2 deletions(-) | |
diff --git a/GVMusicPlayerController/GVMusicPlayerController.m b/GVMusicPlayerController/GVMusicPlayerController.m | |
index cc4bfaf..15c5c8d 100755 | |
--- a/GVMusicPlayerController/GVMusicPlayerController.m | |
+++ b/GVMusicPlayerController/GVMusicPlayerController.m | |
@@ -398,13 +398,21 @@ void audioRouteChangeListenerCallback (void *inUserData, AudioSessionPropertyID | |
MPMediaItemArtwork *artwork = [self.nowPlayingItem valueForProperty:MPMediaItemPropertyArtwork]; | |
MPNowPlayingInfoCenter *center = [playingInfoCenter defaultCenter]; | |
- NSDictionary *songInfo = @{ | |
+ | |
+ NSDictionary *songInfo = @{}; | |
+ | |
+ @try { | |
+ songInfo = @{ | |
MPMediaItemPropertyArtist: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyArtist], | |
MPMediaItemPropertyTitle: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyTitle], | |
MPMediaItemPropertyAlbumTitle: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyAlbumTitle], | |
MPMediaItemPropertyArtwork: artwork, | |
MPMediaItemPropertyPlaybackDuration: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyPlaybackDuration] | |
- }; | |
+ }; | |
+ } | |
+ @catch (NSException * e) { | |
+ NSLog(@"Caught Exception Loading Metadata: %@", e); | |
+ } | |
center.nowPlayingInfo = songInfo; | |
} | |
-- | |
1.8.5.2 (Apple Git-48) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment