Tau: startPlayer() causes PlatformException

Created on 5 Oct 2019  路  5Comments  路  Source: Canardoux/tau

Version 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.

help wanted

Most helpful comment

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.

All 5 comments

Could you also try the example project and compare the differences?

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.

Sounds great! I'll close the issue now~

Thank you for the suggestion. Have a good day.

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edward-yakop picture edward-yakop  路  4Comments

farrelanelca picture farrelanelca  路  5Comments

TharinduNM picture TharinduNM  路  6Comments

felixjunghans picture felixjunghans  路  4Comments

mhstoller picture mhstoller  路  5Comments