Fix completion bug on iOS.
This commit is contained in:
parent
a88669111b
commit
0685398923
|
@ -488,6 +488,8 @@
|
||||||
}
|
}
|
||||||
[self updatePosition];
|
[self updatePosition];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self updateEndAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updatePosition {
|
- (void)updatePosition {
|
||||||
|
@ -629,13 +631,14 @@
|
||||||
} else {
|
} else {
|
||||||
IndexedPlayerItem *endedPlayerItem = (IndexedPlayerItem *)notification.object;
|
IndexedPlayerItem *endedPlayerItem = (IndexedPlayerItem *)notification.object;
|
||||||
IndexedAudioSource *endedSource = endedPlayerItem.audioSource;
|
IndexedAudioSource *endedSource = endedPlayerItem.audioSource;
|
||||||
// When an item ends, seek back to its beginning.
|
|
||||||
[endedSource seek:kCMTimeZero];
|
|
||||||
|
|
||||||
if ([_orderInv[_index] intValue] + 1 < [_order count]) {
|
if ([_orderInv[_index] intValue] + 1 < [_order count]) {
|
||||||
|
// When an item ends, seek back to its beginning.
|
||||||
|
[endedSource seek:kCMTimeZero];
|
||||||
// account for automatic move to next item
|
// account for automatic move to next item
|
||||||
_index = [_order[[_orderInv[_index] intValue] + 1] intValue];
|
_index = [_order[[_orderInv[_index] intValue] + 1] intValue];
|
||||||
NSLog(@"advance to next: index = %d", _index);
|
NSLog(@"advance to next: index = %d", _index);
|
||||||
|
[self updateEndAction];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
} else {
|
} else {
|
||||||
// reached end of playlist
|
// reached end of playlist
|
||||||
|
@ -650,11 +653,13 @@
|
||||||
// sources.
|
// sources.
|
||||||
// For now we just do a seek back to the start.
|
// For now we just do a seek back to the start.
|
||||||
if ([_order count] == 1) {
|
if ([_order count] == 1) {
|
||||||
[self seek:kCMTimeZero index:[NSNull null] completionHandler:^(BOOL finished) {
|
[self seek:kCMTimeZero index:_order[0] completionHandler:^(BOOL finished) {
|
||||||
// XXX: Necessary?
|
// XXX: Necessary?
|
||||||
[self play];
|
[self play];
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
|
// When an item ends, seek back to its beginning.
|
||||||
|
[endedSource seek:kCMTimeZero];
|
||||||
[self seek:kCMTimeZero index:_order[0] completionHandler:^(BOOL finished) {
|
[self seek:kCMTimeZero index:_order[0] completionHandler:^(BOOL finished) {
|
||||||
// XXX: Necessary?
|
// XXX: Necessary?
|
||||||
[self play];
|
[self play];
|
||||||
|
@ -796,6 +801,7 @@
|
||||||
// account for automatic move to next item
|
// account for automatic move to next item
|
||||||
_index = [_order[[_orderInv[_index] intValue] + 1] intValue];
|
_index = [_order[[_orderInv[_index] intValue] + 1] intValue];
|
||||||
NSLog(@"advance to next on error: index = %d", _index);
|
NSLog(@"advance to next on error: index = %d", _index);
|
||||||
|
[self updateEndAction];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"error on last item");
|
NSLog(@"error on last item");
|
||||||
|
@ -808,6 +814,7 @@
|
||||||
// notifying this observer.
|
// notifying this observer.
|
||||||
NSLog(@"Queue change detected. Adjusting index from %d -> %d", _index, expectedIndex);
|
NSLog(@"Queue change detected. Adjusting index from %d -> %d", _index, expectedIndex);
|
||||||
_index = expectedIndex;
|
_index = expectedIndex;
|
||||||
|
[self updateEndAction];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -961,14 +968,16 @@
|
||||||
|
|
||||||
- (void)setLoopMode:(int)loopMode {
|
- (void)setLoopMode:(int)loopMode {
|
||||||
_loopMode = loopMode;
|
_loopMode = loopMode;
|
||||||
if (_player) {
|
[self updateEndAction];
|
||||||
switch (_loopMode) {
|
|
||||||
case loopOne:
|
|
||||||
_player.actionAtItemEnd = AVPlayerActionAtItemEndPause; // AVPlayerActionAtItemEndNone
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_player.actionAtItemEnd = AVPlayerActionAtItemEndAdvance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateEndAction {
|
||||||
|
// Should update this whenever the audio source changes and whenever _index changes.
|
||||||
|
if (!_player) return;
|
||||||
|
if (_audioSource && [_orderInv[_index] intValue] + 1 < [_order count] && _loopMode != loopOne) {
|
||||||
|
_player.actionAtItemEnd = AVPlayerActionAtItemEndAdvance;
|
||||||
|
} else {
|
||||||
|
_player.actionAtItemEnd = AVPlayerActionAtItemEndPause; // AVPlayerActionAtItemEndNone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue