startPlayerFromStream().

The τ Player API


startPlayerFromStream()

This functionnality needs, at least, and Android SDK >= 21

StartPlayerFromStream has 4 optional parameters

  • Codec codec = Codec.pcm16. The only codec supported is actually Codec.pcm16.
  • numChannels = 1. The only value possible for numChannels: is actually 1.
  • sampleRate: = 16000. Is the sample rate of the data you want to play.
  • bufferSize = 8192, is the size of the working buffer. This parameter is used on Android and iOS. The default value is 8192.

Please look to the following notice

Example You can look to the three provided examples :

  • This example shows how to play Live data, with Back Pressure from Flutter Sound
  • This example shows how to play Live data, without Back Pressure from Flutter Sound
  • This example shows how to play some real time sound effects.

Example 1:

await myPlayer.startPlayerFromStream(codec: Codec.pcm16, numChannels: 1, sampleRate: 48000);

await myPlayer.feedFromStream(aBuffer);
await myPlayer.feedFromStream(anotherBuffer);
await myPlayer.feedFromStream(myOtherBuffer);

await myPlayer.stopPlayer();
    );
        Lorem ipsum ...

Example 2:

await myPlayer.startPlayerFromStream(codec: Codec.pcm16, numChannels: 1, sampleRate: 48000);

myPlayer.foodSink.add(FoodData(aBuffer));
myPlayer.foodSink.add(FoodData(anotherBuffer));
myPlayer.foodSink.add(FoodData(myOtherBuffer));

myPlayer.foodSink.add(FoodEvent((){_mPlayer.stopPlayer();}));
        Lorem ipsum ...

Tags: api player