channelMethodCallHandler method
Implementation
Future<bool> channelMethodCallHandler(MethodCall call) {
return Future<bool>(() {
FlutterSoundPlayerCallback aPlayer =
getSession(call.arguments!['slotNo'] as int);
Map arg = call.arguments;
bool success = call.arguments['success'] != null
? call.arguments['success'] as bool
: false;
if (arg['state'] != null) aPlayer.updatePlaybackState(arg['state']);
switch (call.method) {
case "updateProgress":
{
aPlayer.updateProgress(
duration: arg['duration'], position: arg['position']);
}
break;
case "needSomeFood":
{
aPlayer.needSomeFood(arg['arg']);
}
break;
case "audioPlayerFinishedPlaying":
{
aPlayer.audioPlayerFinished(arg['arg']);
}
break;
case 'updatePlaybackState':
{
aPlayer.updatePlaybackState(arg['arg']);
}
break;
case 'openPlayerCompleted':
{
aPlayer.openPlayerCompleted(call.arguments['state'], success);
}
break;
case 'startPlayerCompleted':
{
int duration = arg['duration'] as int;
aPlayer.startPlayerCompleted(
call.arguments['state'], success, duration);
}
break;
case "stopPlayerCompleted":
{
aPlayer.stopPlayerCompleted(call.arguments['state'], success);
}
break;
case "pausePlayerCompleted":
{
aPlayer.pausePlayerCompleted(call.arguments['state'], success);
}
break;
case "resumePlayerCompleted":
{
aPlayer.resumePlayerCompleted(call.arguments['state'], success);
}
break;
case "log":
{
int i = call.arguments['level'];
Level l = Level.values.firstWhere((x) => x.value == i);
aPlayer.log(l, call.arguments['msg']);
}
break;
default:
throw ArgumentError('Unknown method ${call.method}');
}
return success;
});
}