[enh] startPlayerFromAsset()
See original GitHub issueFlutter Sound Version :
-
Released or Beta version ? Released
-
Version number ? 6.4.2+1
-
FULL or LITE flavor ? FULL
-
Result of the command “flutter pub deps | grep flutter_sound” (very important)
|-- flutter_sound 6.4.8+2 | |-- flutter_sound_platform_interface 6.4.8+2 | |-- flutter_sound_web 6.4.8+2 | | |-- flutter_sound_platform_interface…
Severity
- startPlayer exception makes unable to load sound
Platforms you faced the error
Android real device
Logs
(This is very important. Most of the time we cannot do anything if we do not have information on your bug)
(I have no idea even after searching): E/FlautoPlayer(25600): startPlayer() exception E/flutter (25600): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(ERR_UNKNOWN, ERR_UNKNOWN, startPlayer() error, null) E/flutter (25600): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7) E/flutter (25600): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18) E/flutter (25600): <asynchronous suspension> E/flutter (25600): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12) E/flutter (25600): #3 MethodChannelFlutterSoundPlayer.invokeMethod (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:161:21) E/flutter (25600): #4 MethodChannelFlutterSoundPlayer.startPlayer (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:227:14) E/flutter (25600): #5 FlutterSoundPlayer.startPlayer.<anonymous closure> (package:flutter_sound/public/flutter_sound_player.dart:870:61) E/flutter (25600): <asynchronous suspension> E/flutter (25600): #6 FlutterSoundPlayer.startPlayer.<anonymous closure> (package:flutter_sound/public/flutter_sound_player.dart) E/flutter (25600): #7 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26) E/flutter (25600): #8 FlutterSoundPlayer.startPlayer (package:flutter_sound/public/flutter_sound_player.dart:852:17) E/flutter (25600): #9 SoundManager.playUserAudioButton.<anonymous closure> (package:quiz/src/sound_manager.dart:95:32) E/flutter (25600): #10 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19) E/flutter (25600): #11 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38) E/flutter (25600): #12 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24) E/flutter (25600): #13 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11) E/flutter (25600): #14 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5) E/flutter (25600): #15 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7) E/flutter (25600): #16 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9) E/flutter (25600): #17 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12) E/flutter (25600): #18 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9) E/flutter (25600): #19 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8) E/flutter (25600): #20 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18) E/flutter (25600): #21 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7) E/flutter (25600): #22 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19) E/flutter (25600): #23 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22) E/flutter (25600): #24 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11) E/flutter (25600): #25 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7) E/flutter (25600): #26 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7) E/flutter (25600): #27 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7) E/flutter (25600): #28 _rootRunUnary (dart:async/zone.dart:1206:13) E/flutter (25600): #29 _CustomZone.runUnary (dart:async/zone.dart:1100:19) E/flutter (25600): #30 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7) E/flutter (25600): #31 _invoke1 (dart:ui/hooks.dart:265:10) E/flutter (25600): #32 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
Screenshots
(If applicable, add screenshots to help explain your problem).
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior: Compile and run with Android Studio
import 'package:flutter_sound/flutter_sound.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var _audioPlayer = FlutterSoundPlayer();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: playUserAudioButton()),
);
}
Widget playUserAudioButton() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
child: Text('test'),
onPressed: () async {
_audioPlayer = await _audioPlayer.openAudioSession();
await _audioPlayer.startPlayer(fromURI: 'assets/audio/001.mp3');
},
),
);
}
}```
**Expected behavior**
A clear and concise description of what you expected to happen.
Play the media file
-----------------------------------------------------------------
## Additional context**
Add any other context about the problem here.
The debug message is so unclear
Issue Analytics
- State:
- Created 3 years ago
- Comments:15
Top GitHub Comments
👍 @Alvarocda . This was my fault. I forgot to tell you that Tau Sound has a git subproject : tau_native
If you look to this diagram you can see that the τ project is architectured with 3 layers. Actually, your development of “Play from Asset” will impact only the High level in Dart (Platform Support). So the change the two lines of build.gradle is OK. If you will want to do other developments in the future, then I will explain you how to develop in the Low level.
Sorry for not having told you. Congratulation to have found yourself how to fix your issue.
So I cloned the repository, created a flutter project and added the dependency using the static path. However, when running the project I’m using to test, it presents me with some errors.
The first time I tried it, it gave me the following error:
I went into that file and commented out this line (line 57).
Then I tried to compile again and my console was full of errors.
So, I went back to this file /home/alvarocda/desenvolvimento/alvaro/tau10/tau_sound/android/build.gradle and noticed that under line 57 there was another commented line of implementation, I uncommented this line (line 58) and the project started to run normally.
Is that so or did I do something wrong?