Skip to content

Commit

Permalink
FIX: Fixed crash in demo project that would occur when trying to acce…
Browse files Browse the repository at this point in the history
…ss “Local Music Library” in simulator (fixes douban#38).
  • Loading branch information
Wolfgang Timme committed Mar 20, 2014
1 parent 1cb0ee1 commit 92d7ad4
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions example/DOUASDemo/DOUASDemo/PlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92d7ad4

Please sign in to comment.