Tau: [HELP] Audio Player - player is not set

Created on 4 Sep 2020  路  10Comments  路  Source: Canardoux/tau

I need Help for :

  • Using the API ?
    Yes, I Play (a recorded audio) from local and remote

  • Generate an iOS or Android App ?
    Starting from iOS and wait Recording Opus OGG on android to extends also on Android devices

  • Debugging my App ?
    Not sure


Here is my question :

Hi guys,
thanks a lot for this great job you are doing...

My app records Opus OGG files on iOS, send them to remote server, then play on another device.

I am correctly recording files on iOS and I am sure it works, because I tried with another client.

Unfortunately I have an issue while I am trying to reproduce the recorded audio from my app.

I did many tries including playing the remote file example, but it is not working.

I am facing this issue:

Debugging the code I am able to see the full message that is raised by:

flutter_sound_player.dart:649
Future startPlayerFromTrack( Track track,
...
await lock.synchronized(() async {
Raise:
PlatformException(FAILED, startPlayerFromTrack(), null)

Then in message_codecs.dart:571
Error Code: Audio Player
Error Message: player is not set

The code (snippets) are:

Called from page widget initialization

  _initSoundPlayer() async {
    await _soundPlayer.openAudioSessionWithUI(
        focus: AudioFocus.requestFocusTransient,
        category: SessionCategory.playAndRecord,
        mode: SessionMode.modeDefault,
        device: AudioDevice.speaker,
        audioFlags: outputToSpeaker | allowBlueTooth | allowHeadset);
    await _soundPlayer.setSubscriptionDuration(Duration(milliseconds: 10));
  }

Called from UI Tap

  _playMessage(P2TMessage message, Function whenFinished) async {

    var onError = (err) => print("Error playing track ${message.id}: $err");
    final track = await _getAudioTrack(message);

    try {
      print("Set Volume to 70%");
      _soundPlayer.setVolume(0.7);
      await _soundPlayer
          .startPlayerFromTrack(track, whenFinished: whenFinished)
          .catchError(onError);
    } catch (e) {
      print("Exception paying message id: ${message.id}");
      print(e);
    }
  }

I am not sure what to use between openAudioSessionWithUI or openAudioSession... In both case is not working...
I also checked info.plist and I have this:

    <key>UIBackgroundModes</key>
    <array>
            <!-- ... -->
            <string>audio</string>
    </array>

Any idea?

Thanks a lot, Davide.

#Updates
Local played file URI is: file:///var/mobile/Containers/Data/Application/${DEVICE_UUID}/Documents/audio/2020-09-04-12-09-35-689.ogg

help wanted

All 10 comments

Hi, davide,

I am not sure what to use between openAudioSessionWithUI or openAudioSession... In both case is not working...

I suggest that for starting you use openAudioSession() wich is simpler that openAudioSessionWithUI(), and that you will switch to openAudioSessionWithUI() later, if you really want to manage your App from the lock-screen.

If you use openAudioSession(), you must call startPlayer() to playback your record, and not startPlayerFromTrack. Again, you will switch to startPlayerFromTrack() later, if you need to control from the lock-screen.

Are you sure that your OGG record is OPUS codec and not VORBIS codec ?
On iOS, actually, Flutter Sound cannot play directely VORBIS. If your file is VORBIS, you must decode/recode your record, using "FFmpeg"

Note : OPUS is really a great CODEC. Unfortunately, as always, Apple does not want to follow the standards, and use its own file format CAF to store OPUS data, instead of the regular OGG format.
Before playing an OPUS file stored in an OGG envelope, flutter sound remux the OGG to CAF, using FFmpeg.
This is transparent for the APP, but you should see the FFmpeg logs when you try to play your record.

If you are stuck, post your OGG file, and your complete logs.
Good luck.

Of course it is MANDATORY to specify opusOGG as your codec, when you try to playback an OPUS record.
Perhaps this is just what you forgot ?

Hi Larpoux, thanks for your quick reply,
I am sure I set Opus OGG codec:

    _recorderModule.startRecorder(
      toFile: _recordingPath,
      codec: Codec.opusOGG,
      bitRate: _sampleRate,
      sampleRate: _sampleRate,
    );

I try to add codec, if will not work I continue following your steps.

Thanks!
Davide

Davide,
Playing OPUS/OGG on iOS needs Flutter Sound FULL flavor. The LITE flavor will not work

Davide,

Playing OPUS/OGG on iOS needs Flutter Sound FULL flavor. The LITE flavor will not work

Sure! I'm using the full version.

Now with your updates is working correctly using local file and data buffer, but not yet the remote file, I am still investigating on this..

Thanks, Dabide

Davide,
I do not think that playing OPUS on iOS from a remote file works correctly.
This has probably not be tested by anybody.

To play OPUS on iOS, Flutter Sound must convert the OGG format to the CAF Apple proprietary format.
If the file is remote, Flutter Sound cannot do this REMUX with FFmpeg.
If you must play such a file, you must download it to local, and then play the local file

Hi Larpoux, I found the issue...
the problem is not about remote, because I downloaded the file before.
Unfortunately the server I am using converts the file in AMR NB format before to give me back the file.
I see that AMR NB file format is not supported by flutter_sound yet.

Do you plan to add this support?

Thanks, Davide.

Actually we have too much work and not many (hum!) developers.
AMR/NB is OK on Android, but is not supported natively by ios.

Probably, you should convert your file to PCM/WAV before playing it (FFmpeg is easy for such a task).

Ok Larpoux, it is working fine, we changed the server implementation and now is using Opus / OGG File, but I download the file locally before to play.

Thanks for your help.

Davide.

馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

farrelanelca picture farrelanelca  路  5Comments

deepbluev7 picture deepbluev7  路  5Comments

PabloduPontavice picture PabloduPontavice  路  3Comments

alby97 picture alby97  路  5Comments

gtilson picture gtilson  路  5Comments