startPlayer() causes PlatformException
See original GitHub issueVersion of flutter_sound
1.4.8
flutter doctor
[√] Flutter (Channel stable, v1.9.1+hotfix.4, on Microsoft Windows [Versione 10.0.18362.388], locale it-IT)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [!] Android Studio (version 3.4) X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. [√] VS Code (version 1.38.1) [√] VS Code, 64-bit edition [√] Connected device (1 available)
Platforms you faced the error (IOS or Android or both?)
Android
Expected behavior
Play the audio file
Actual behavior
Gives PlatformException
Tested environment (Emulator? Real Device?)
Emulator
Steps to reproduce the behavior
This is my code:
void startPlayer() async { print(_filePath); String path = await flutterSound.startPlayer(_filePath); await flutterSound.setVolume(1.0); try { _playerSubscription = flutterSound.onPlayerStateChanged.listen((e) { if (e != null) { sliderCurrentPosition = e.currentPosition; maxDuration = e.duration; DateTime date = new DateTime.fromMillisecondsSinceEpoch( e.currentPosition.toInt(), ); String txt = DateFormat('mm:ss:SS', "it_IT").format(date); this.setState(() { this._playerTxt = txt.substring(0, 8); if (_isPlaying == false) { _isPlaying = true; } }); } else { this.setState(() { _isPlaying = false; }); } }); } catch (e) {} }
It could be that the problem is the custom path that is passed as parameter in _flutterSound.startPlayer()?
This is the exception when i press on the button that fire my callback startPlayer (code above):
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Exception: PlatformException(ERR_UNKNOWN, ERR_UNKNOWN, Prepare failed.: status=0x1) E/flutter (15855): #0 FlutterSound.startPlayer package:flutter_sound/flutter_sound.dart:18
Tell me if I have to give you more info.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top GitHub Comments
I tried to reproduce the same issue on your example project and I found the “problem”, my file path contained colon and blank spaces, these caused the exception. So, I replaced them with underscore and now works properly in both project.
This needs to be in the docs!