Fix compiler warnings.
This commit is contained in:
parent
62fe5b6ab9
commit
741facb0dc
|
@ -20,7 +20,7 @@
|
||||||
AVQueuePlayer *_player;
|
AVQueuePlayer *_player;
|
||||||
AudioSource *_audioSource;
|
AudioSource *_audioSource;
|
||||||
NSMutableArray<IndexedAudioSource *> *_indexedAudioSources;
|
NSMutableArray<IndexedAudioSource *> *_indexedAudioSources;
|
||||||
NSMutableArray<NSNumber *> *_order;
|
NSArray<NSNumber *> *_order;
|
||||||
NSMutableArray<NSNumber *> *_orderInv;
|
NSMutableArray<NSNumber *> *_orderInv;
|
||||||
int _index;
|
int _index;
|
||||||
enum ProcessingState _processingState;
|
enum ProcessingState _processingState;
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
@try {
|
@try {
|
||||||
NSDictionary *request = (NSDictionary *)call.arguments;
|
NSDictionary *request = (NSDictionary *)call.arguments;
|
||||||
if ([@"load" isEqualToString:call.method]) {
|
if ([@"load" isEqualToString:call.method]) {
|
||||||
CMTime initialPosition = request[@"initialPosition"] == [NSNull null] ? kCMTimeZero : CMTimeMake([request[@"initialPosition"] longLongValue], 1000000);
|
CMTime initialPosition = request[@"initialPosition"] == (id)[NSNull null] ? kCMTimeZero : CMTimeMake([request[@"initialPosition"] longLongValue], 1000000);
|
||||||
[self load:request[@"audioSource"] initialPosition:initialPosition initialIndex:request[@"initialIndex"] result:result];
|
[self load:request[@"audioSource"] initialPosition:initialPosition initialIndex:request[@"initialIndex"] result:result];
|
||||||
} else if ([@"play" isEqualToString:call.method]) {
|
} else if ([@"play" isEqualToString:call.method]) {
|
||||||
[self play:result];
|
[self play:result];
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
[self setAutomaticallyWaitsToMinimizeStalling:(BOOL)[request[@"enabled"] boolValue]];
|
[self setAutomaticallyWaitsToMinimizeStalling:(BOOL)[request[@"enabled"] boolValue]];
|
||||||
result(@{});
|
result(@{});
|
||||||
} else if ([@"seek" isEqualToString:call.method]) {
|
} else if ([@"seek" isEqualToString:call.method]) {
|
||||||
CMTime position = request[@"position"] == [NSNull null] ? kCMTimePositiveInfinity : CMTimeMake([request[@"position"] longLongValue], 1000000);
|
CMTime position = request[@"position"] == (id)[NSNull null] ? kCMTimePositiveInfinity : CMTimeMake([request[@"position"] longLongValue], 1000000);
|
||||||
[self seek:position index:request[@"index"] completionHandler:^(BOOL finished) {
|
[self seek:position index:request[@"index"] completionHandler:^(BOOL finished) {
|
||||||
result(@{});
|
result(@{});
|
||||||
}];
|
}];
|
||||||
|
@ -135,6 +135,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (AVQueuePlayer *)player {
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float)speed {
|
||||||
|
return _speed;
|
||||||
|
}
|
||||||
|
|
||||||
// Untested
|
// Untested
|
||||||
- (void)concatenatingAdd:(NSString *)catId source:(NSDictionary *)source {
|
- (void)concatenatingAdd:(NSString *)catId source:(NSDictionary *)source {
|
||||||
[self concatenatingInsertAll:catId index:-1 sources:@[source]];
|
[self concatenatingInsertAll:catId index:-1 sources:@[source]];
|
||||||
|
@ -177,7 +185,7 @@
|
||||||
}
|
}
|
||||||
[self updateOrder];
|
[self updateOrder];
|
||||||
if (_player.currentItem) {
|
if (_player.currentItem) {
|
||||||
_index = [self indexForItem:_player.currentItem];
|
_index = [self indexForItem:(IndexedPlayerItem *)_player.currentItem];
|
||||||
} else {
|
} else {
|
||||||
_index = 0;
|
_index = 0;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +232,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self updateOrder];
|
[self updateOrder];
|
||||||
if (_index >= _indexedAudioSources.count) _index = _indexedAudioSources.count - 1;
|
if (_index >= _indexedAudioSources.count) _index = (int)_indexedAudioSources.count - 1;
|
||||||
if (_index < 0) _index = 0;
|
if (_index < 0) _index = 0;
|
||||||
[self enqueueFrom:_index];
|
[self enqueueFrom:_index];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
|
@ -244,7 +252,7 @@
|
||||||
_indexedAudioSources = [[NSMutableArray alloc] init];
|
_indexedAudioSources = [[NSMutableArray alloc] init];
|
||||||
[_audioSource buildSequence:_indexedAudioSources treeIndex:0];
|
[_audioSource buildSequence:_indexedAudioSources treeIndex:0];
|
||||||
[self updateOrder];
|
[self updateOrder];
|
||||||
[self enqueueFrom:[self indexForItem:_player.currentItem]];
|
[self enqueueFrom:[self indexForItem:(IndexedPlayerItem *)_player.currentItem]];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +319,7 @@
|
||||||
// TODO: buffer position
|
// TODO: buffer position
|
||||||
@"bufferedPosition": @((long long)1000 * _updatePosition),
|
@"bufferedPosition": @((long long)1000 * _updatePosition),
|
||||||
// TODO: Icy Metadata
|
// TODO: Icy Metadata
|
||||||
@"icyMetadata": [NSNull null],
|
@"icyMetadata": (id)[NSNull null],
|
||||||
@"duration": @((long long)1000 * [self getDuration]),
|
@"duration": @((long long)1000 * [self getDuration]),
|
||||||
@"currentIndex": @(_index),
|
@"currentIndex": @(_index),
|
||||||
});
|
});
|
||||||
|
@ -403,7 +411,7 @@
|
||||||
audioSources:[self decodeAudioSources:data[@"children"]]];
|
audioSources:[self decodeAudioSources:data[@"children"]]];
|
||||||
} else if ([@"clipping" isEqualToString:type]) {
|
} else if ([@"clipping" isEqualToString:type]) {
|
||||||
return [[ClippingAudioSource alloc] initWithId:data[@"id"]
|
return [[ClippingAudioSource alloc] initWithId:data[@"id"]
|
||||||
audioSource:[self decodeAudioSource:data[@"child"]]
|
audioSource:(UriAudioSource *)[self decodeAudioSource:data[@"child"]]
|
||||||
start:data[@"start"]
|
start:data[@"start"]
|
||||||
end:data[@"end"]];
|
end:data[@"end"]];
|
||||||
} else if ([@"looping" isEqualToString:type]) {
|
} else if ([@"looping" isEqualToString:type]) {
|
||||||
|
@ -427,7 +435,7 @@
|
||||||
/* [self dumpQueue]; */
|
/* [self dumpQueue]; */
|
||||||
|
|
||||||
// First, remove all _player items except for the currently playing one (if any).
|
// First, remove all _player items except for the currently playing one (if any).
|
||||||
IndexedPlayerItem *oldItem = _player.currentItem;
|
IndexedPlayerItem *oldItem = (IndexedPlayerItem *)_player.currentItem;
|
||||||
IndexedPlayerItem *existingItem = nil;
|
IndexedPlayerItem *existingItem = nil;
|
||||||
IndexedPlayerItem *newItem = _indexedAudioSources.count > 0 ? _indexedAudioSources[_index].playerItem : nil;
|
IndexedPlayerItem *newItem = _indexedAudioSources.count > 0 ? _indexedAudioSources[_index].playerItem : nil;
|
||||||
NSArray *oldPlayerItems = [NSArray arrayWithArray:_player.items];
|
NSArray *oldPlayerItems = [NSArray arrayWithArray:_player.items];
|
||||||
|
@ -497,7 +505,7 @@
|
||||||
}
|
}
|
||||||
_initialPos = initialPosition;
|
_initialPos = initialPosition;
|
||||||
_loadResult = result;
|
_loadResult = result;
|
||||||
_index = (initialIndex != [NSNull null]) ? [initialIndex intValue] : 0;
|
_index = (initialIndex != (id)[NSNull null]) ? [initialIndex intValue] : 0;
|
||||||
_processingState = loading;
|
_processingState = loading;
|
||||||
[self updatePosition];
|
[self updatePosition];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
|
@ -604,12 +612,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onItemStalled:(NSNotification *)notification {
|
- (void)onItemStalled:(NSNotification *)notification {
|
||||||
IndexedPlayerItem *playerItem = (IndexedPlayerItem *)notification.object;
|
//IndexedPlayerItem *playerItem = (IndexedPlayerItem *)notification.object;
|
||||||
NSLog(@"onItemStalled");
|
NSLog(@"onItemStalled");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onFailToComplete:(NSNotification *)notification {
|
- (void)onFailToComplete:(NSNotification *)notification {
|
||||||
IndexedPlayerItem *playerItem = (IndexedPlayerItem *)notification.object;
|
//IndexedPlayerItem *playerItem = (IndexedPlayerItem *)notification.object;
|
||||||
NSLog(@"onFailToComplete");
|
NSLog(@"onFailToComplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +820,7 @@
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
int expectedIndex = [self indexForItem:_player.currentItem];
|
int expectedIndex = [self indexForItem:(IndexedPlayerItem *)_player.currentItem];
|
||||||
if (_index != expectedIndex) {
|
if (_index != expectedIndex) {
|
||||||
// AVQueuePlayer will sometimes skip over error items without
|
// AVQueuePlayer will sometimes skip over error items without
|
||||||
// notifying this observer.
|
// notifying this observer.
|
||||||
|
@ -851,9 +859,9 @@
|
||||||
[weakSelf updatePosition];
|
[weakSelf updatePosition];
|
||||||
[weakSelf broadcastPlaybackEvent];
|
[weakSelf broadcastPlaybackEvent];
|
||||||
if (shouldResumePlayback) {
|
if (shouldResumePlayback) {
|
||||||
_player.actionAtItemEnd = originalEndAction;
|
weakSelf.player.actionAtItemEnd = originalEndAction;
|
||||||
// TODO: This logic is almost duplicated in seek. See if we can reuse this code.
|
// TODO: This logic is almost duplicated in seek. See if we can reuse this code.
|
||||||
_player.rate = _speed;
|
weakSelf.player.rate = weakSelf.speed;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
|
@ -872,7 +880,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendErrorForItem:(IndexedPlayerItem *)playerItem {
|
- (void)sendErrorForItem:(IndexedPlayerItem *)playerItem {
|
||||||
FlutterError *flutterError = [FlutterError errorWithCode:[NSString stringWithFormat:@"%d", playerItem.error.code]
|
FlutterError *flutterError = [FlutterError errorWithCode:[NSString stringWithFormat:@"%d", (int)playerItem.error.code]
|
||||||
message:playerItem.error.localizedDescription
|
message:playerItem.error.localizedDescription
|
||||||
details:nil];
|
details:nil];
|
||||||
[self sendError:flutterError playerItem:playerItem];
|
[self sendError:flutterError playerItem:playerItem];
|
||||||
|
@ -1025,7 +1033,7 @@
|
||||||
|
|
||||||
- (void)dumpQueue {
|
- (void)dumpQueue {
|
||||||
for (int i = 0; i < _player.items.count; i++) {
|
for (int i = 0; i < _player.items.count; i++) {
|
||||||
IndexedPlayerItem *playerItem = _player.items[i];
|
IndexedPlayerItem *playerItem = (IndexedPlayerItem *)_player.items[i];
|
||||||
for (int j = 0; j < _indexedAudioSources.count; j++) {
|
for (int j = 0; j < _indexedAudioSources.count; j++) {
|
||||||
IndexedAudioSource *source = _indexedAudioSources[j];
|
IndexedAudioSource *source = _indexedAudioSources[j];
|
||||||
if (source.playerItem == playerItem) {
|
if (source.playerItem == playerItem) {
|
||||||
|
@ -1053,7 +1061,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int index = _index;
|
int index = _index;
|
||||||
if (newIndex != [NSNull null]) {
|
if (newIndex != (id)[NSNull null]) {
|
||||||
index = [newIndex intValue];
|
index = [newIndex intValue];
|
||||||
}
|
}
|
||||||
if (index != _index) {
|
if (index != _index) {
|
||||||
|
@ -1084,10 +1092,10 @@
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
[source seek:position completionHandler:^(BOOL finished) {
|
[source seek:position completionHandler:^(BOOL finished) {
|
||||||
if (@available(macOS 10.12, iOS 10.0, *)) {
|
if (@available(macOS 10.12, iOS 10.0, *)) {
|
||||||
if (_playing) {
|
if (self->_playing) {
|
||||||
// Handled by timeControlStatus
|
// Handled by timeControlStatus
|
||||||
} else {
|
} else {
|
||||||
if (_bufferUnconfirmed && !_player.currentItem.playbackBufferFull) {
|
if (self->_bufferUnconfirmed && !self->_player.currentItem.playbackBufferFull) {
|
||||||
// Stay in buffering
|
// Stay in buffering
|
||||||
} else if (source.playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
} else if (source.playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
||||||
[self leaveBuffering:@"seek to index finished, (!bufferUnconfirmed || playbackBufferFull) && ready to play"];
|
[self leaveBuffering:@"seek to index finished, (!bufferUnconfirmed || playbackBufferFull) && ready to play"];
|
||||||
|
@ -1096,7 +1104,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_bufferUnconfirmed && !_player.currentItem.playbackBufferFull) {
|
if (self->_bufferUnconfirmed && !self->_player.currentItem.playbackBufferFull) {
|
||||||
// Stay in buffering
|
// Stay in buffering
|
||||||
} else if (source.playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
} else if (source.playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
||||||
[self leaveBuffering:@"seek to index finished, (!bufferUnconfirmed || playbackBufferFull) && ready to play"];
|
[self leaveBuffering:@"seek to index finished, (!bufferUnconfirmed || playbackBufferFull) && ready to play"];
|
||||||
|
@ -1104,10 +1112,10 @@
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_playing) {
|
if (self->_playing) {
|
||||||
_player.rate = _speed;
|
self->_player.rate = self->_speed;
|
||||||
}
|
}
|
||||||
_seekPos = kCMTimeInvalid;
|
self->_seekPos = kCMTimeInvalid;
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(finished);
|
completionHandler(finished);
|
||||||
|
@ -1140,10 +1148,9 @@
|
||||||
[self enterBuffering:@"seek"];
|
[self enterBuffering:@"seek"];
|
||||||
[self updatePosition];
|
[self updatePosition];
|
||||||
[self broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
__weak __typeof__(self) weakSelf = self;
|
|
||||||
[_indexedAudioSources[_index] seek:position completionHandler:^(BOOL finished) {
|
[_indexedAudioSources[_index] seek:position completionHandler:^(BOOL finished) {
|
||||||
[weakSelf updatePosition];
|
[self updatePosition];
|
||||||
if (_playing) {
|
if (self->_playing) {
|
||||||
// If playing, buffering will be detected either by:
|
// If playing, buffering will be detected either by:
|
||||||
// 1. checkForDiscontinuity
|
// 1. checkForDiscontinuity
|
||||||
// 2. timeControlStatus
|
// 2. timeControlStatus
|
||||||
|
@ -1152,27 +1159,27 @@
|
||||||
// detect buffering when buffered audio is not immediately
|
// detect buffering when buffered audio is not immediately
|
||||||
// available.
|
// available.
|
||||||
//[_player playImmediatelyAtRate:_speed];
|
//[_player playImmediatelyAtRate:_speed];
|
||||||
_player.rate = _speed;
|
self->_player.rate = self->_speed;
|
||||||
} else {
|
} else {
|
||||||
_player.rate = _speed;
|
self->_player.rate = self->_speed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If not playing, there is no reliable way to detect
|
// If not playing, there is no reliable way to detect
|
||||||
// when buffering has completed, so we use
|
// when buffering has completed, so we use
|
||||||
// !playbackBufferEmpty. Although this always seems to
|
// !playbackBufferEmpty. Although this always seems to
|
||||||
// be full even right after a seek.
|
// be full even right after a seek.
|
||||||
if (_player.currentItem.playbackBufferEmpty) {
|
if (self->_player.currentItem.playbackBufferEmpty) {
|
||||||
[weakSelf enterBuffering:@"seek finished, playbackBufferEmpty"];
|
[self enterBuffering:@"seek finished, playbackBufferEmpty"];
|
||||||
} else {
|
} else {
|
||||||
[weakSelf leaveBuffering:@"seek finished, !playbackBufferEmpty"];
|
[self leaveBuffering:@"seek finished, !playbackBufferEmpty"];
|
||||||
}
|
}
|
||||||
[weakSelf updatePosition];
|
[self updatePosition];
|
||||||
if (_processingState != buffering) {
|
if (self->_processingState != buffering) {
|
||||||
[weakSelf broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_seekPos = kCMTimeInvalid;
|
self->_seekPos = kCMTimeInvalid;
|
||||||
[weakSelf broadcastPlaybackEvent];
|
[self broadcastPlaybackEvent];
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(finished);
|
completionHandler(finished);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getShuffleOrder {
|
- (NSArray<NSNumber *> *)getShuffleOrder {
|
||||||
return @[];
|
return @[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
self = [super initWithId:sid];
|
self = [super initWithId:sid];
|
||||||
NSAssert(self, @"super init cannot be nil");
|
NSAssert(self, @"super init cannot be nil");
|
||||||
_audioSource = audioSource;
|
_audioSource = audioSource;
|
||||||
_start = start == [NSNull null] ? kCMTimeZero : CMTimeMake([start longLongValue], 1000000);
|
_start = start == (id)[NSNull null] ? kCMTimeZero : CMTimeMake([start longLongValue], 1000000);
|
||||||
_end = end == [NSNull null] ? kCMTimeInvalid : CMTimeMake([end longLongValue], 1000000);
|
_end = end == (id)[NSNull null] ? kCMTimeInvalid : CMTimeMake([end longLongValue], 1000000);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
return _audioSource.playerItem;
|
return _audioSource.playerItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getShuffleOrder {
|
- (NSArray<NSNumber *> *)getShuffleOrder {
|
||||||
return @[@(0)];
|
return @[@(0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)count {
|
- (int)count {
|
||||||
return _audioSources.count;
|
return (int)_audioSources.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertSource:(AudioSource *)audioSource atIndex:(int)index {
|
- (void)insertSource:(AudioSource *)audioSource atIndex:(int)index {
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeSourcesFromIndex:(int)start toIndex:(int)end {
|
- (void)removeSourcesFromIndex:(int)start toIndex:(int)end {
|
||||||
if (end == -1) end = _audioSources.count;
|
if (end == -1) end = (int)_audioSources.count;
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
[_audioSources removeObjectAtIndex:start];
|
[_audioSources removeObjectAtIndex:start];
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getShuffleOrder {
|
- (NSArray<NSNumber *> *)getShuffleOrder {
|
||||||
NSMutableArray *order = [NSMutableArray new];
|
NSMutableArray<NSNumber *> *order = [NSMutableArray new];
|
||||||
int offset = [order count];
|
int offset = (int)[order count];
|
||||||
NSMutableArray *childOrders = [NSMutableArray new]; // array of array of ints
|
NSMutableArray<NSArray<NSNumber *> *> *childOrders = [NSMutableArray new]; // array of array of ints
|
||||||
for (int i = 0; i < [_audioSources count]; i++) {
|
for (int i = 0; i < [_audioSources count]; i++) {
|
||||||
AudioSource *audioSource = _audioSources[i];
|
AudioSource *audioSource = _audioSources[i];
|
||||||
NSArray *childShuffleOrder = [audioSource getShuffleOrder];
|
NSArray<NSNumber *> *childShuffleOrder = [audioSource getShuffleOrder];
|
||||||
NSMutableArray *offsetChildShuffleOrder = [NSMutableArray new];
|
NSMutableArray<NSNumber *> *offsetChildShuffleOrder = [NSMutableArray new];
|
||||||
for (int j = 0; j < [childShuffleOrder count]; j++) {
|
for (int j = 0; j < [childShuffleOrder count]; j++) {
|
||||||
[offsetChildShuffleOrder addObject:@([childShuffleOrder[j] integerValue] + offset)];
|
[offsetChildShuffleOrder addObject:@([childShuffleOrder[j] integerValue] + offset)];
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
for (int i = 0; i < [_audioSources count]; i++) {
|
for (int i = 0; i < [_audioSources count]; i++) {
|
||||||
[_shuffleOrder addObject:@(0)];
|
[_shuffleOrder addObject:@(0)];
|
||||||
}
|
}
|
||||||
NSLog(@"shuffle: audioSources.count=%d and shuffleOrder.count=%d", [_audioSources count], [_shuffleOrder count]);
|
NSLog(@"shuffle: audioSources.count=%d and shuffleOrder.count=%d", (int)[_audioSources count], (int)[_shuffleOrder count]);
|
||||||
// First generate a random shuffle
|
// First generate a random shuffle
|
||||||
for (int i = 0; i < [_audioSources count]; i++) {
|
for (int i = 0; i < [_audioSources count]; i++) {
|
||||||
int j = arc4random_uniform(i + 1);
|
int j = arc4random_uniform(i + 1);
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getShuffleOrder {
|
- (NSArray<NSNumber *> *)getShuffleOrder {
|
||||||
NSMutableArray *order = [NSMutableArray new];
|
NSMutableArray<NSNumber *> *order = [NSMutableArray new];
|
||||||
int offset = (int)[order count];
|
int offset = (int)[order count];
|
||||||
for (int i = 0; i < [_audioSources count]; i++) {
|
for (int i = 0; i < [_audioSources count]; i++) {
|
||||||
AudioSource *audioSource = _audioSources[i];
|
AudioSource *audioSource = _audioSources[i];
|
||||||
NSArray *childShuffleOrder = [audioSource getShuffleOrder];
|
NSArray<NSNumber *> *childShuffleOrder = [audioSource getShuffleOrder];
|
||||||
for (int j = 0; j < [childShuffleOrder count]; j++) {
|
for (int j = 0; j < [childShuffleOrder count]; j++) {
|
||||||
[order addObject:@([childShuffleOrder[j] integerValue] + offset)];
|
[order addObject:@([childShuffleOrder[j] integerValue] + offset)];
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
return _playerItem;
|
return _playerItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getShuffleOrder {
|
- (NSArray<NSNumber *> *)getShuffleOrder {
|
||||||
return @[@(0)];
|
return @[@(0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#import <Flutter/Flutter.h>
|
#import <Flutter/Flutter.h>
|
||||||
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
@interface AudioPlayer : NSObject<FlutterStreamHandler>
|
@interface AudioPlayer : NSObject<FlutterStreamHandler>
|
||||||
|
|
||||||
|
@property (readonly, nonatomic) AVQueuePlayer *player;
|
||||||
|
@property (readonly, nonatomic) float speed;
|
||||||
|
|
||||||
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam;
|
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam;
|
||||||
- (void)dispose;
|
- (void)dispose;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
- (instancetype)initWithId:(NSString *)sid;
|
- (instancetype)initWithId:(NSString *)sid;
|
||||||
- (int)buildSequence:(NSMutableArray *)sequence treeIndex:(int)treeIndex;
|
- (int)buildSequence:(NSMutableArray *)sequence treeIndex:(int)treeIndex;
|
||||||
- (void)findById:(NSString *)sourceId matches:(NSMutableArray<AudioSource *> *)matches;
|
- (void)findById:(NSString *)sourceId matches:(NSMutableArray<AudioSource *> *)matches;
|
||||||
- (NSArray *)getShuffleOrder;
|
- (NSArray<NSNumber *> *)getShuffleOrder;
|
||||||
- (int)shuffle:(int)treeIndex currentIndex:(int)currentIndex;
|
- (int)shuffle:(int)treeIndex currentIndex:(int)currentIndex;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#import <FlutterMacOS/FlutterMacOS.h>
|
#import <FlutterMacOS/FlutterMacOS.h>
|
||||||
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
@interface AudioPlayer : NSObject<FlutterStreamHandler>
|
@interface AudioPlayer : NSObject<FlutterStreamHandler>
|
||||||
|
|
||||||
|
@property (readonly, nonatomic) AVQueuePlayer *player;
|
||||||
|
@property (readonly, nonatomic) float speed;
|
||||||
|
|
||||||
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam;
|
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar playerId:(NSString*)idParam;
|
||||||
- (void)dispose;
|
- (void)dispose;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
- (instancetype)initWithId:(NSString *)sid;
|
- (instancetype)initWithId:(NSString *)sid;
|
||||||
- (int)buildSequence:(NSMutableArray *)sequence treeIndex:(int)treeIndex;
|
- (int)buildSequence:(NSMutableArray *)sequence treeIndex:(int)treeIndex;
|
||||||
- (void)findById:(NSString *)sourceId matches:(NSMutableArray<AudioSource *> *)matches;
|
- (void)findById:(NSString *)sourceId matches:(NSMutableArray<AudioSource *> *)matches;
|
||||||
- (NSArray *)getShuffleOrder;
|
- (NSArray<NSNumber *> *)getShuffleOrder;
|
||||||
- (int)shuffle:(int)treeIndex currentIndex:(int)currentIndex;
|
- (int)shuffle:(int)treeIndex currentIndex:(int)currentIndex;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue