Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
867 stars 567 forks source link

[BUG]: The recorded audio does not play on web #678

Closed satyajitghana closed 3 years ago

satyajitghana commented 3 years ago

Flutter Sound Version :

|-- flutter_sound 8.1.1
|   |-- flutter...
|   |-- flutter_sound_platform_interface 8.1.1
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface...
|   |-- flutter_sound_web 8.1.1
|   |   |-- flutter...
|   |   |-- flutter_sound_platform_interface...
|   |   |-- flutter_web_plugins...
|   |   |-- js...
|   |   '-- meta...
|   |-- flutter_spinkit 5.0.0
|   |   '-- flutter...
|   |-- logger 1.0.0
|   |-- path...
|   |-- path_provider...
|   |-- provider 5.0.0
|   |   |-- collection...
|   |   |-- flutter...
|   |   '-- nested 1.0.0
|   |       '-- flutter...

Severity


Platforms you faced the error


Describe the bug

  Future<String> getTempAudioFile() async {
    var uuid = Uuid();
    String path;
    var tmpDir = await getTemporaryDirectory();
    path = '${join(tmpDir.path, uuid.v4())}.m4a';
    var parent = dirname(path);
    Directory(parent).createSync(recursive: true);

    return path;
  }

  Future<void> resetAudioTrack() async {
    String path = await getTempAudioFile();
    recordingFile = path;
    track = Track(trackPath: recordingFile, codec: Codec.aacMP4);
    setState(() {});
  }

The Audio is supposed to be recorded as aacMP4, but i am not able to play this audio on a web browser. It DOES play on VLC

This is what vlc shows the codec as image

To Reproduce Steps to reproduce the behavior:

  1. Record audio as per give above code
  2. embed the audio on web using
<audio controls>
      <source src="b82ebf5d-6198-4032-98bf-bf93ffcd24e6_1621252991.m4a" type="audio/ogg">
</audio>

NOTE: The file type audio/ogg doesn't really affect it to be not playing, it should still work.

BUT If I use ffmpeg to simply convert this to a standard AAC/MP3 format it DOES play on web.


Logs!!!!

W/cident_reporte(24534): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
I/flutter (24534): FS:---> openAudioSession 
I/flutter (24534): ---> openAudioSession
I/flutter (24534): Resetting flutter_sound Recorder Plugin
I/AudioManager(24534): In stopBluetoothSco(), calling application:
I/AudioManager(24534): In setBluetoothScoOn(), on: false, calling application: 
I/AudioManager(24534): In setSpeakerphoneOn(), on: true, calling application: 
I/AudioManager(24534): In setSpeakerphoneOn(), on: true, calling application: 
I/AudioManager(24534): In setBluetoothScoOn(), on: false, calling application: 
I/AudioManager(24534): In stopBluetoothSco(), calling application: 
I/flutter (24534): ---> openRecorderCompleted: true
I/flutter (24534): <--- openRecorderCompleted: true
I/flutter (24534): <--- openAudioSession
I/flutter (24534): FS:<--- openAudioSession 
I/flutter (24534): FS:---> startRecorder 
I/flutter (24534): FS:---> _startRecorder.
I/flutter (24534): Calling instance.startRecorder
I/flutter (24534): ---> startRecorderCompleted: true
I/flutter (24534): <--- startRecorderCompleted: true
I/flutter (24534): FS:<--- _startRecorder.
I/flutter (24534): FS:<--- startRecorder 
W/cident_reporte(24534): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/cident_reporte(24534): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
I/flutter (24534): FS:---> stopRecorder 
I/flutter (24534): FS:---> stopRecorder 
I/flutter (24534): FS:---> stop
I/flutter (24534): ---> stopRecorderCompleted: true
I/flutter (24534): <---- stopRecorderCompleted: true
I/flutter (24534): FS:<--- stop
I/flutter (24534): FS:<--- stopRecorder : /data/user/0/cache/b82ebf5d-6198-4032-98bf-bf93ffcd24e6.m4a
I/flutter (24534): FS:<--- stopRecorder 
I/flutter (24534): FS:---> closeAudioSession 
I/flutter (24534): FS:---> closeAudioSession 
I/flutter (24534): FS:---> stop
I/flutter (24534): ---> stopRecorderCompleted: true
I/flutter (24534): <---- stopRecorderCompleted: true
I/flutter (24534): FS:<--- stop
I/flutter (24534): FS:---> openAudioSession
I/flutter (24534): Resetting flutter_sound Player Plugin
I/flutter (24534): ---> closeRecorderCompleted
I/flutter (24534): <--- closeRecorderCompleted
I/flutter (24534): FS:<--- closeAudioSession 
I/flutter (24534): FS:<--- closeAudioSession 
D/MediaBrowserCompat(24534): Connecting to a MediaBrowserService.
I/AudioManager(24534): In stopBluetoothSco(), calling application: 
I/AudioManager(24534): In setBluetoothScoOn(), on: false, calling application: 
I/AudioManager(24534): In setSpeakerphoneOn(), on: true, calling application: 
I/AudioManager(24534): In setSpeakerphoneOn(), on: true, calling application: 
I/AudioManager(24534): In setBluetoothScoOn(), on: false, calling application: 
I/AudioManager(24534): In stopBluetoothSco(), calling application:
I/flutter (24534): FS:<--- openAudioSession
I/flutter (24534): FS:---> channelMethodCallHandler : openPlayerCompleted
I/flutter (24534): ---> openPlayerCompleted: true
I/flutter (24534): <--- openPlayerCompleted: true
I/flutter (24534): FS:<--- channelMethodCallHandler : openPlayerCompleted
I/flutter (24534): FS:---> setSubscriptionDuration 
I/flutter (24534): FS:<---- setSubscriptionDuration 
I/flutter (24534): FS:---> startPlayerFromTrack 
I/flutter (24534): FS:---> stop 
I/flutter (24534): FS:---> channelMethodCallHandler : stopPlayerCompleted
E/MediaPlayerNative(24534): stop called in state 1, mPlayer(0x0)
E/MediaPlayerNative(24534): error (-38, 0)
I/flutter (24534): ---> stopPlayerCompleted: true
I/flutter (24534): <--- stopPlayerCompleted: true
I/flutter (24534): FS:<--- channelMethodCallHandler : stopPlayerCompleted
I/flutter (24534): FS:<--- stop 
V/MediaPlayer(24534): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(24534): cleanDrmObj: mDrmObj=null mDrmSessionId=null
I/flutter (24534): FS:---> _convert 
I/flutter (24534): FS:---> needToConvert 
I/flutter (24534): FS:<--- needToConvert 
I/flutter (24534): FS:<--- _convert 
I/flutter (24534): FS:---> channelMethodCallHandler : updatePlaybackState
I/flutter (24534): FS:<--- channelMethodCallHandler : updatePlaybackState
I/flutter (24534): FS:---> channelMethodCallHandler : stopPlayerCompleted
I/flutter (24534): ---> stopPlayerCompleted: true
I/flutter (24534): Error : cannot process stopPlayerCompleted
I/flutter (24534): <--- stopPlayerCompleted: true
I/flutter (24534): FS:<--- channelMethodCallHandler : stopPlayerCompleted
E/MediaPlayerNative(24534): stop called in state 0, mPlayer(0x0)
I/flutter (24534): FS:<--- startPlayerFromTrack 
V/MediaPlayer(24534): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(24534): cleanDrmObj: mDrmObj=null mDrmSessionId=null
I/flutter (24534): FS:---> channelMethodCallHandler : updatePlaybackState
I/flutter (24534): FS:<--- channelMethodCallHandler : updatePlaybackState
V/MediaPlayer(24534): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(24534): cleanDrmObj: mDrmObj=null mDrmSessionId=null
I/flutter (24534): FS:---> channelMethodCallHandler : startPlayerCompleted
I/flutter (24534): ---> startPlayerCompleted: true
I/flutter (24534): <--- startPlayerCompleted: true
I/flutter (24534): FS:<--- channelMethodCallHandler : startPlayerCompleted
I/flutter (24534): FS:---> channelMethodCallHandler : updatePlaybackState
I/flutter (24534): FS:<--- channelMethodCallHandler : updatePlaybackState
I/flutter (24534): FS:---> pausePlayer 
I/flutter (24534): FS:---> _pausePlayer 
I/flutter (24534): FS:---> channelMethodCallHandler : pausePlayerCompleted
I/flutter (24534): ---> pausePlayerCompleted: true
I/flutter (24534): <--- pausePlayerCompleted: true
I/flutter (24534): FS:<--- channelMethodCallHandler : pausePlayerCompleted
I/flutter (24534): FS:<--- _pausePlayer 
I/flutter (24534): FS:<--- pausePlayer 

satyajitghana commented 3 years ago

Fixed it, had to use the Codec in recorder as well, i thought mentioning it in Track was enough

Larpoux commented 3 years ago

Good point. This must be improved.