From 92d7ad41ba6422da52e3ae43bea322ef5ca86ef6 Mon Sep 17 00:00:00 2001 From: Wolfgang Timme Date: Thu, 20 Mar 2014 21:32:21 +0100 Subject: [PATCH] =?UTF-8?q?FIX:=20Fixed=20crash=20in=20demo=20project=20th?= =?UTF-8?q?at=20would=20occur=20when=20trying=20to=20access=20=E2=80=9CLoc?= =?UTF-8?q?al=20Music=20Library=E2=80=9D=20in=20simulator=20(fixes=20#38).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DOUASDemo/PlayerViewController.m | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/example/DOUASDemo/DOUASDemo/PlayerViewController.m b/example/DOUASDemo/DOUASDemo/PlayerViewController.m index 6e815e1..ac6004f 100644 --- a/example/DOUASDemo/DOUASDemo/PlayerViewController.m +++ b/example/DOUASDemo/DOUASDemo/PlayerViewController.m @@ -126,19 +126,26 @@ - (void)_resetStreamer { [self _cancelStreamer]; - Track *track = [_tracks objectAtIndex:_currentTrackIndex]; - NSString *title = [NSString stringWithFormat:@"%@ - %@", track.artist, track.title]; - [_titleLabel setText:title]; - - _streamer = [DOUAudioStreamer streamerWithAudioFile:track]; - [_streamer addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:kStatusKVOKey]; - [_streamer addObserver:self forKeyPath:@"duration" options:NSKeyValueObservingOptionNew context:kDurationKVOKey]; - [_streamer addObserver:self forKeyPath:@"bufferingRatio" options:NSKeyValueObservingOptionNew context:kBufferingRatioKVOKey]; - - [_streamer play]; - - [self _updateBufferingStatus]; - [self _setupHintForStreamer]; + if (0 == [_tracks count]) + { + [_miscLabel setText:@"(No tracks available)"]; + } + else + { + Track *track = [_tracks objectAtIndex:_currentTrackIndex]; + NSString *title = [NSString stringWithFormat:@"%@ - %@", track.artist, track.title]; + [_titleLabel setText:title]; + + _streamer = [DOUAudioStreamer streamerWithAudioFile:track]; + [_streamer addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:kStatusKVOKey]; + [_streamer addObserver:self forKeyPath:@"duration" options:NSKeyValueObservingOptionNew context:kDurationKVOKey]; + [_streamer addObserver:self forKeyPath:@"bufferingRatio" options:NSKeyValueObservingOptionNew context:kBufferingRatioKVOKey]; + + [_streamer play]; + + [self _updateBufferingStatus]; + [self _setupHintForStreamer]; + } } - (void)_setupHintForStreamer