startPlayer method

  1. @override
Future<int> startPlayer(
  1. TauPlayerCallback callback, {
  2. Codec? codec,
  3. Uint8List? fromDataBuffer,
  4. String? fromURI,
  5. int? numChannels,
  6. int? sampleRate,
})
override

Implementation

@override
Future<int> startPlayer(TauPlayerCallback callback,  {Codec? codec, Uint8List? fromDataBuffer, String?  fromURI, int? numChannels, int? sampleRate}) async
{
        // startPlayerCompleter = new Completer<Map>();
        // await invokeMethod( callback, 'startPlayer', {'codec': codec.index, 'fromDataBuffer': fromDataBuffer, 'fromURI': fromURI, 'numChannels': numChannels, 'sampleRate': sampleRate},) ;
        // return  startPlayerCompleter.future ;
        // String s = "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3";
        if (codec == null)
                codec = Codec.defaultCodec;
        if (fromDataBuffer != null)
        {
                if (fromURI != null)
                {
                        throw Exception("You may not specify both 'fromURI' and 'fromDataBuffer' parameters");
                }
                //js.context.callMethod('playAudioFromBuffer', [fromDataBuffer]);
                //playAudioFromBuffer(fromDataBuffer);
                // .......................return getWebSession(callback).playAudioFromBuffer(fromDataBuffer);
                //playAudioFromBuffer3(fromDataBuffer);
                //Directory tempDir = await getTemporaryDirectory();
                /*
                String path = defaultExtensions[codec.index];
                File filOut = File(path);
                IOSink sink = filOut.openWrite();
                sink.add(fromDataBuffer.toList());
                fromURI = path;
                 */
        }
        //js.context.callMethod('playAudioFromURL', [fromURI]);
        callback.log(Level.debug, 'startPlayer FromURI : $fromURI');
        return getWebSession(callback)!.startPlayer(codec.index,  fromDataBuffer, fromURI, numChannels, sampleRate);
}