Time stretching, AndroidX, update gradle
This commit is contained in:
parent
a50daad9e1
commit
b93611dca3
19 changed files with 1963 additions and 160 deletions
|
@ -60,6 +60,9 @@
|
|||
} else if ([@"setVolume" isEqualToString:call.method]) {
|
||||
[self setVolume:(float)[args[0] doubleValue]];
|
||||
result(nil);
|
||||
} else if ([@"setSpeed" isEqualToString:call.method]) {
|
||||
[self setSpeed:(float)[args[0] doubleValue]];
|
||||
result(nil);
|
||||
} else if ([@"seek" isEqualToString:call.method]) {
|
||||
[self seek:[args[0] intValue] result:result];
|
||||
result(nil);
|
||||
|
@ -92,7 +95,7 @@
|
|||
long long now = (long long)([[NSDate date] timeIntervalSince1970] * 1000.0);
|
||||
int position = [self getCurrentPosition];
|
||||
long long timeSinceLastUpdate = now - _updateTime;
|
||||
long long expectedPosition = _updatePosition + timeSinceLastUpdate;
|
||||
long long expectedPosition = _updatePosition + timeSinceLastUpdate; // TODO: * speed
|
||||
long long drift = position - expectedPosition;
|
||||
// Update if we've drifted or just started observing
|
||||
if (_updateTime == 0L) {
|
||||
|
@ -257,6 +260,14 @@
|
|||
[_player setVolume:volume];
|
||||
}
|
||||
|
||||
- (void)setSpeed:(float)speed {
|
||||
//if (speed == 1.0
|
||||
// || speed < 1.0 && _player.currentItem.canPlaySlowForward
|
||||
// || speed > 1.0 && _player.currentItem.canPlayFastForward) {
|
||||
// _player.rate = speed;
|
||||
//}
|
||||
}
|
||||
|
||||
- (void)seek:(int)position result:(FlutterResult)result {
|
||||
_stateBeforeSeek = _state;
|
||||
_seekPos = position;
|
||||
|
|
|
@ -3,32 +3,33 @@
|
|||
#import "AudioPlayer.h"
|
||||
|
||||
@implementation JustAudioPlugin {
|
||||
NSObject<FlutterPluginRegistrar>* _registrar;
|
||||
NSObject<FlutterPluginRegistrar>* _registrar;
|
||||
}
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
FlutterMethodChannel* channel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"com.ryanheise.just_audio.methods"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
JustAudioPlugin* instance = [[JustAudioPlugin alloc] initWithRegistrar:registrar];
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
FlutterMethodChannel* channel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"com.ryanheise.just_audio.methods"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
JustAudioPlugin* instance = [[JustAudioPlugin alloc] initWithRegistrar:registrar];
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
}
|
||||
|
||||
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
self = [super init];
|
||||
NSAssert(self, @"super init cannot be nil");
|
||||
_registrar = registrar;
|
||||
return self;
|
||||
self = [super init];
|
||||
NSAssert(self, @"super init cannot be nil");
|
||||
_registrar = registrar;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
||||
if ([@"init" isEqualToString:call.method]) {
|
||||
NSString* playerId = call.arguments;
|
||||
AudioPlayer* player = [[AudioPlayer alloc] initWithRegistrar:_registrar playerId:playerId];
|
||||
result(nil);
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
if ([@"init" isEqualToString:call.method]) {
|
||||
NSArray* args = (NSArray*)call.arguments;
|
||||
NSString* playerId = args[0];
|
||||
AudioPlayer* player = [[AudioPlayer alloc] initWithRegistrar:_registrar playerId:playerId];
|
||||
result(nil);
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue