Canardoux / flutter_sound

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

[BUG]: Unhandled Exception: type 'bool' is not a subtype of type 'int' in type cast #631

Open marcoberetta96 opened 3 years ago

marcoberetta96 commented 3 years ago

Flutter Sound Version : 7.7.0+1

Severity: result is not what expected

Platforms you faced the error: Android, Emulator


Describe the bug Can't reproduce audio from headset. [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'bool' is not a subtype of type 'int' in type cast** Same error occurs when calling await _playerModule.setAudioFocus();

To Reproduce

      await _playerModule.setAudioFocus(
          focus: AudioFocus.requestFocusAndKeepOthers,
          category: SessionCategory.playback,
          mode: SessionMode.modeDefault,
          device: AudioDevice.headset,
          audioFlags:allowHeadset
      );

Logs

I/flutter (15968): <--- startPlayerCompleted: true
I/flutter (15968): FS:<--- channelMethodCallHandler : startPlayerCompleted
I/flutter (15968): FS:---> setAudioFocus 
E/flutter (15968): **[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'bool' is not a subtype of type 'int' in type cast**
E/flutter (15968): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:41)
E/flutter (15968): <asynchronous suspension>
E/flutter (15968): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (15968): #2      MethodChannelFlutterSoundPlayer.invokeMethod (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:192:21)
E/flutter (15968): #3      MethodChannelFlutterSoundPlayer.setAudioFocus (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:227:12)
E/flutter (15968): #4      FlutterSoundPlayer._setAudioFocus (package:flutter_sound/public/flutter_sound_player.dart:745:59)
E/flutter (15968): <asynchronous suspension>
E/flutter (15968): #5      FlutterSoundPlayer.setAudioFocus.<anonymous closure> (package:flutter_sound/public/flutter_sound_player.dart:722:13)
E/flutter (15968): #6      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26)
E/flutter (15968): #7      FlutterSoundPlayer.setAudioFocus (package:flutter_sound/public/flutter_sound_player.dart:721:17)
E/flutter (15968): #8      _MyAppState._startPlayer (package:faceroom/screens/chat/messages/audio_player_widget.dart:205:29)
E/flutter (15968): <asynchronous suspension>
E/flutter (15968): #9      _MyAppState._onStartPlayerPressed (package:faceroom/screens/chat/messages/audio_player_widget.dart:248:34)
E/flutter (15968): #10     _MyAppState.build.<anonymous closure> (package:faceroom/screens/chat/messages/audio_player_widget.dart:287:38)
E/flutter (15968): #11     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter (15968): #12     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter (15968): #13     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (15968): #14     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (15968): #15     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (15968): #16     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
E/flutter (15968): #17     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter (15968): #18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:362:20)
E/flutter (15968): #19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
E/flutter (15968): #20     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
E/flutter (15968): #21     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
E/flutter (15968): #22     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
E/flutter (15968): #23     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
E/flutter (15968): #24     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (15968): #25     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (15968): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (15968): #27     _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (15968): #28     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter (15968): 
D/FlautoPlayer(15968): Playback completed.
V/MediaPlayer(15968): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(15968): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(15968): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(15968): cleanDrmObj: mDrmObj=null mDrmSessionId=null
I/flutter (15968): FS:---> channelMethodCallHandler : audioPlayerFinishedPlaying
I/flutter (15968): FS:---> audioPlayerFinished
I/flutter (15968): FS:---> stopPlayer 
I/flutter (15968): FS:---> stop 
marcoberetta96 commented 3 years ago

The bug persists with version 8.0.0+6

marcoberetta96 commented 3 years ago

The issue is here:

E/flutter (19531): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type 'bool' is not a subtype of type 'int' in type cast
E/flutter (19531): #0      MethodChannelFlutterSoundPlayer.invokeMethod (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:184:58)
E/flutter (19531): <asynchronous suspension>
E/flutter (19531): #1      FlutterSoundPlayer._setAudioFocus (package:flutter_sound/public/flutter_sound_player.dart:732:17)
E/flutter (19531): <asynchronous suspension>
E/flutter (19531): #2      FlutterSoundPlayer.setAudioFocus.<anonymous closure> (package:flutter_sound/public/flutter_sound_player.dart:709:7)
E/flutter (19531): <asynchronous suspension>
E/flutter (19531): #3      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter (19531): <asynchronous suspension>
E/flutter (19531): #4      FlutterSoundPlayer.setAudioFocus (package:flutter_sound/public/flutter_sound_player.dart:708:5)
Larpoux commented 3 years ago

@marcoberetta96 , Please could you check if your issue is fixed in Flutter Sound 8.0.2 ?

marcoberetta96 commented 3 years ago

@Larpoux the unhandled exception has now disappeared, thank you.

Unfortunately now I'm not able anymore to set an AudioDevice through either openAudioSession() or setAudioFocus(). The audio is always reproduced using AudioDevice.speaker.

Please let me know if I should open another issue. I think that a code snippet is not useful because I'm not able to change from AudioDevice.speaker in any case. Please let me know and thank you!

marcoberetta96 commented 3 years ago

I have just made some tests with the new flutter_sound 8.1.1 and unfortunately I'm still not able to to set an AudioDevice through either openAudioSession() or setAudioFocus(). Thank you.

marcoberetta96 commented 3 years ago

Hi @Larpoux have you any update on this?

marcoberetta96 commented 3 years ago

Hi @Larpoux I have just tried with flutter_sound 8.1.4 Have you any update on this?

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.