You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HELP] Unable to play remote file due to AudioPlayer initialisation timeout #13
I'm trying to play play() a track from a remote url using Track.fromURL(). When I feed this track to my SoundPlayer().play(track), I'm getting an error due to AudioPlayer initialisation timeout from the SoundPlayer's _initializeAndRun method. I'm not sure why it's failing. It appears to be happening on both an iOS simulator and an Android device. If I don't provide a coded or provide a Codec.fromExtension, I get a uri error: The uri's extension does not match any of the supported extensions. You must pass in a codec.. I'm trying to play files from Firebase Storage, so the links don't have a file extension in the url.
So with no extension you definitely need to pass a codec.
Can you post the log messages including a stack trace.
This may be a little hard to track down at the moment. I'm in the middle of some large changes (moving from codec to MediaFormat). I should have these changes nailed down in the next week at which point I will be in a better position to assist.
Can you try passing a url from another source. One theory is that fire base isn't returning the file.
I've just release 0.9.0 which has changed from a Codec to a MediaFormat.
It also has a significant no. of fixes for ios.
There is still a bug with getDuration which I should have fixed in the next 48hours.
I'm trying to get it to build, but it keep failing with the changes to the media format and I'm not sure how to get it set it. I'm trying to just use a MediaFormat aac for recording but that doesn't appear to be an option and I'm not sure how the MediaFormat is really intended to work, so I haven't been able to test playing (though I need to stream the audio and not have to wait for full download everytime so I might not even be able to use sounds for this). I'll keep testing and see how to get it to work and try and come up with some documentation updates!
Edit: I was able to get it to build. It looks like rather than using MediaFormat, we need to use WellKnownMediaFormat to specify a specific preset media format!
EDIT: Saw your comment to try a file stored elsewhere. I tried to play the following file: https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_2MG.mp3, but get the same result (AudioPlayer initialisation timeout).
On Thu, 2 Jul 2020, 3:22 am Kyle Banta, ***@***.***> wrote:
I am still getting 2 errors when trying to play a remote file on iOS:
The first time I try to play a file after starting the app, I get this
error:
flutter: \^[[38;5;249m01 10:17:57.398 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method initializeMediaPlayer on channel com.bsutton.sounds.sounds_shade_player)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 BasePlugin.invokeMethod (package:sounds/src/plugins/base_plugin.dart:112:27)
#3 PlayerBasePlugin.initializePlayer (package:sounds/src/plugins/player_base_plugin.dart:56:11)
#4 SoundPlayer._initializeAndRun (package:sounds/src/sound_player.dart:237:21)
#5 SoundPlayer.play (package:sounds/src/sound_player.dart:325:12)
#6 MainAppProvider.playPost (package:Perkl/main.dart:107:25)
#7 Timeline.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:Perkl/Timeline.dart:136:131)
#8 _InkResponseState._handleTap (package:flutter/src/materia<…>
And then every time I try to play a file after that first one, I get the
AudioPlayer initialisation timeout:
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: AudioPlayer initialisation timeout.
#0 SoundPlayer._initializeAndRun.<anonymous closure> (package:sounds/src/sound_player.dart:251:9)
#1 _rootRunUnary (dart:async/zone.dart:1192:38)
#2 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#5 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#6 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:391:9)
#7 _rootRun (dart:async/zone.dart:1184:13)
#8 _CustomZone.run (dart:async/zone.dart:1077:19)
#9 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#10 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#11 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#12 _startMicrotaskLoop (dart:async/schedule_microtask.dart<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Bad state: Cannot add new events after calling close
#0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:251:24)
#1 AudioPlayer.state= (package:audioplayers/audioplayers.dart:174:28)
#2 AudioPlayer.stop (package:audioplayers/audioplayers.dart:418:7)
<asynchronous suspension>
#3 MainAppProvider.playPost (package:Perkl/main.dart:87:14)
#4 Timeline.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:Perkl/Timeline.dart:136:131)
#5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
#7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#9 BaseTapGestureRecognizer._checkUp (package:flutter/s<…>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OFBIMXBBJ4LGF7O7O3RZNWFVANCNFSM4OGHATYA>
.
On Thu, 2 Jul 2020 at 03:22, Kyle Banta ***@***.***> wrote:
I am still getting 2 errors when trying to play a remote file on iOS:
The first time I try to play a file after starting the app, I get this
error:
flutter: \^[[38;5;249m01 10:17:57.398 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method initializeMediaPlayer on channel com.bsutton.sounds.sounds_shade_player)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 BasePlugin.invokeMethod (package:sounds/src/plugins/base_plugin.dart:112:27)
#3 PlayerBasePlugin.initializePlayer (package:sounds/src/plugins/player_base_plugin.dart:56:11)
#4 SoundPlayer._initializeAndRun (package:sounds/src/sound_player.dart:237:21)
#5 SoundPlayer.play (package:sounds/src/sound_player.dart:325:12)
#6 MainAppProvider.playPost (package:Perkl/main.dart:107:25)
#7 Timeline.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:Perkl/Timeline.dart:136:131)
#8 _InkResponseState._handleTap (package:flutter/src/materia<…>
And then every time I try to play a file after that first one, I get the
AudioPlayer initialisation timeout:
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: AudioPlayer initialisation timeout.
#0 SoundPlayer._initializeAndRun.<anonymous closure> (package:sounds/src/sound_player.dart:251:9)
#1 _rootRunUnary (dart:async/zone.dart:1192:38)
#2 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#5 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#6 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:391:9)
#7 _rootRun (dart:async/zone.dart:1184:13)
#8 _CustomZone.run (dart:async/zone.dart:1077:19)
#9 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#10 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#11 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#12 _startMicrotaskLoop (dart:async/schedule_microtask.dart<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Bad state: Cannot add new events after calling close
#0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:251:24)
#1 AudioPlayer.state= (package:audioplayers/audioplayers.dart:174:28)
#2 AudioPlayer.stop (package:audioplayers/audioplayers.dart:418:7)
<asynchronous suspension>
#3 MainAppProvider.playPost (package:Perkl/main.dart:87:14)
#4 Timeline.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:Perkl/Timeline.dart:136:131)
#5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
#7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#9 BaseTapGestureRecognizer._checkUp (package:flutter/s<…>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OFBIMXBBJ4LGF7O7O3RZNWFVANCNFSM4OGHATYA>
.
I've just published 1.0.0-beta.3 which fixes this and a couple of other shade related issues.
I've added a test button to the demo to test shade playback.
I've not had a chance to test this on iOS as yet but it 'should' be ok as the iOS issue was pretty minor.
I'm trying to get it to build, but it keep failing with the changes to the media format and I'm not sure how to get it set it. I'm trying to just use a MediaFormat aac for recording but that doesn't appear to be an option and I'm not sure how the MediaFormat is really intended to work, so I haven't been able to test playing (though I need to stream the audio and not have to wait for full download everytime so I might not even be able to use sounds for this). I'll keep testing and see how to get it to work and try and come up with some documentation updates!
Edit: I was able to get it to build. It looks like rather than using MediaFormat, we need to use WellKnownMediaFormat to specify a specific preset media format!
Yes the MediaFormat is an abstract class. You should either use a WellKnowMediaFormat or one of the formats derived from NativeMediaFormat.
I'm trying to get it to build, but it keep failing with the changes to the media format and I'm not sure how to get it set it. I'm trying to just use a MediaFormat aac for recording but that doesn't appear to be an option and I'm not sure how the MediaFormat is really intended to work, so I haven't been able to test playing (though I need to stream the audio and not have to wait for full download everytime so I might not even be able to use sounds for this). I'll keep testing and see how to get it to work and try and come up with some documentation updates!
Edit: I was able to get it to build. It looks like rather than using MediaFormat, we need to use WellKnownMediaFormat to specify a specific preset media format!
I've updated the SoundRecording doco to go into some more details on the NativeMediaFormats:
So using beta3, on iOS simulator, the first file I try to play, it will open the file in a web browser on my machine and play it (not within the emulator). Every subsequent attempt to play another file results in the same
On Thu, 2 Jul 2020, 10:15 am Kyle Banta, ***@***.***> wrote:
So using beta3, on iOS simulator, the first file I try to play, it will
open the file in a web browser on my machine and play it (not within the
emulator). Every subsequent attempt to play another file results in the same
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: AudioPlayer initialisation timeout.
#0 SoundPlayer._initializeAndRun.<anonymous closure> (package:sounds/src/sound_player.dart:245:9)
#1 _rootRunUnary (dart:async/zone.dart:1192:38)
#2 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#5 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#6 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:391:9)
#7 _rootRun (dart:async/zone.dart:1184:13)
#8 _CustomZone.run (dart:async/zone.dart:1077:19)
#9 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#10 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#11 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#12 _startMicrotaskLoop (dart:async/schedule_microtask.dart<…>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OCWQHUKKCKRPWRBXOLRZPGSFANCNFSM4OGHATYA>
.
This may cause problems if both are trying to utilise the underlying audio player, which might explain the timeout.
But if you are saying that sounds is launching a web browser then that makes no sense at all.
Sounds download the url using the Downloader class:
var client = HttpClient();
unawaited(client.getUrl(Uri.parse(url)).then((request) {
/// we have connected
/// we can added headers here if we need.
/// send the request
return request.close();
}).then((response) async {
I don't see any way that this could cause a browser to open so I think you have problems in other pieces of your code.
I should also note that the download of the url happens in dart code so running on ios should have no affect. I also know that using a remote url works as the demo app does it and that works correctly on android and ios.
I haven't been able to reproduce it opening the file in a web browser. I waited to get my hands on a friend's iPhone to test on device rather than emulator. They act mostly the same, but some small differences:
On Emulator - the first file I try to play just outputs this: flutter: \^[[38;5;249m01 22:40:59.81 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>, but doesn't start playing anything or throw any error. Any file after the first one I try to play throws the AudioPlayer initialisation timeout error.
On Device - every file I try to play just outputs flutter: \^[[38;5;249m01 22:40:59.81 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>, but don't throw the AudioPlayer initialisation timeout error when I try to play subsequent files (they each just output like the first file).
Neither device nor emulator actually plays the audio though.
Here's my code (I commented out the audioplayers stuff, though its still in my dependency list, I was using it because flutter_sound awhile back was failing to play for me and audioplayers was working, though its no longer working for many files):
That one time I ran it, since I was running it on an emulator on a computer, it shifted focus from the emulator to a chrome browser on the computer (not within the emulator) and opened the file. But this hasn't happened any other time, so I'm not sure what happened that one time, but I'm not sure its an issue since I can't get it to happen again.
I'm trying to also test on android to see if its just an iOS issue, but I can't get any android builds to work due to [ ] [ +2 ms] Target kernel_snapshot failed: FileSystemException: Cannot open file, path = '/Users/mbpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/sounds-1.0.0-beta.3/.packages' (OS Error: No such file or directory, errno = 2). I've been working through this with some others on the flutter discord and another user mentioned he also gets this same error trying to build just the starter app from flutter create after adding the sounds beta package. So I'm not sure I'm able to test this beta on android either.
Activity
bsutton commentedon Jun 27, 2020
So with no extension you definitely need to pass a codec.
Can you post the log messages including a stack trace.
This may be a little hard to track down at the moment. I'm in the middle of some large changes (moving from codec to MediaFormat). I should have these changes nailed down in the next week at which point I will be in a better position to assist.
Can you try passing a url from another source. One theory is that fire base isn't returning the file.
bsutton commentedon Jun 28, 2020
I've just release 0.9.0 which has changed from a Codec to a MediaFormat.
It also has a significant no. of fixes for ios.
There is still a bug with getDuration which I should have fixed in the next 48hours.
bsutton commentedon Jun 30, 2020
The 1.0 beta is more released.
See if that reduces your issues.
kbanta11 commentedon Jul 1, 2020
I'm trying to get it to build, but it keep failing with the changes to the media format and I'm not sure how to get it set it. I'm trying to just use a MediaFormat aac for recording but that doesn't appear to be an option and I'm not sure how the MediaFormat is really intended to work, so I haven't been able to test playing (though I need to stream the audio and not have to wait for full download everytime so I might not even be able to use sounds for this). I'll keep testing and see how to get it to work and try and come up with some documentation updates!
Edit: I was able to get it to build. It looks like rather than using MediaFormat, we need to use WellKnownMediaFormat to specify a specific preset media format!
kbanta11 commentedon Jul 1, 2020
I am still getting 2 errors when trying to play a remote file on iOS:
The first time I try to play a file after starting the app, I get this error:
And then every time I try to play a file after that first one, I get the AudioPlayer initialisation timeout:
EDIT: Saw your comment to try a file stored elsewhere. I tried to play the following file:
https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_2MG.mp3, but get the same result (AudioPlayer initialisation timeout).bsutton commentedon Jul 1, 2020
bsutton commentedon Jul 1, 2020
bsutton commentedon Jul 1, 2020
I've just published 1.0.0-beta.3 which fixes this and a couple of other shade related issues.
I've added a test button to the demo to test shade playback.
I've not had a chance to test this on iOS as yet but it 'should' be ok as the iOS issue was pretty minor.
bsutton commentedon Jul 1, 2020
Yes the MediaFormat is an abstract class. You should either use a WellKnowMediaFormat or one of the formats derived from NativeMediaFormat.
kbanta11 commentedon Jul 1, 2020
Yes, I was beta2. Will upgrade to beta3 and try shortly.
bsutton commentedon Jul 1, 2020
I've updated the SoundRecording doco to go into some more details on the NativeMediaFormats:
https://github.com/bsutton/sounds/wiki/SoundRecorder
kbanta11 commentedon Jul 2, 2020
So using beta3, on iOS simulator, the first file I try to play, it will open the file in a web browser on my machine and play it (not within the emulator). Every subsequent attempt to play another file results in the same
Edit: Going to try with an actual iOS device this evening when I have one available to test with
bsutton commentedon Jul 2, 2020
bsutton commentedon Jul 2, 2020
I also see a mention of another sound package in your stacktrace:
0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:251:24)
#1 AudioPlayer.state= (package:audioplayers/audioplayers.dart:174:28)
#2 AudioPlayer.stop (package:audioplayers/audioplayers.dart:418:7)
#3 MainAppProvider.playPost (package:Perkl/main.dart:87:14)
This may cause problems if both are trying to utilise the underlying audio player, which might explain the timeout.
But if you are saying that sounds is launching a web browser then that makes no sense at all.
Sounds download the url using the Downloader class:
var client = HttpClient();
unawaited(client.getUrl(Uri.parse(url)).then((request) {
/// we have connected
/// we can added headers here if we need.
/// send the request
return request.close();
}).then((response) async {
I don't see any way that this could cause a browser to open so I think you have problems in other pieces of your code.
bsutton commentedon Jul 2, 2020
I should also note that the download of the url happens in dart code so running on ios should have no affect. I also know that using a remote url works as the demo app does it and that works correctly on android and ios.
kbanta11 commentedon Jul 2, 2020
I haven't been able to reproduce it opening the file in a web browser. I waited to get my hands on a friend's iPhone to test on device rather than emulator. They act mostly the same, but some small differences:
On Emulator - the first file I try to play just outputs this:
flutter: \^[[38;5;249m01 22:40:59.81 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>, but doesn't start playing anything or throw any error. Any file after the first one I try to play throws theAudioPlayer initialisation timeouterror.On Device - every file I try to play just outputs
flutter: \^[[38;5;249m01 22:40:59.81 Debug base_plugin.dart : BasePlugin.invokeMethod : 114 ::: invokeMethod returned for initializeMediaPlayer slot: 0<…>, but don't throw theAudioPlayer initialisation timeouterror when I try to play subsequent files (they each just output like the first file).Neither device nor emulator actually plays the audio though.
Here's my code (I commented out the
audioplayersstuff, though its still in my dependency list, I was using it becauseflutter_soundawhile back was failing to play for me and audioplayers was working, though its no longer working for many files):bsutton commentedon Jul 2, 2020
What exactly do you mean by this statement. You keep talking about a web browser but I don't understand its relavance.
Are you just saying that you can open the url in a web browser and it will play or do you mean that the app causes a web browser to open?
kbanta11 commentedon Jul 2, 2020
That one time I ran it, since I was running it on an emulator on a computer, it shifted focus from the emulator to a chrome browser on the computer (not within the emulator) and opened the file. But this hasn't happened any other time, so I'm not sure what happened that one time, but I'm not sure its an issue since I can't get it to happen again.
I'm trying to also test on android to see if its just an iOS issue, but I can't get any android builds to work due to
[ ] [ +2 ms] Target kernel_snapshot failed: FileSystemException: Cannot open file, path = '/Users/mbpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/sounds-1.0.0-beta.3/.packages' (OS Error: No such file or directory, errno = 2). I've been working through this with some others on the flutter discord and another user mentioned he also gets this same error trying to build just the starter app fromflutter createafter adding the sounds beta package. So I'm not sure I'm able to test this beta on android either.bsutton commentedon Jul 2, 2020
I can't connect to my mac right at the moment but I've dropped your code into the demo app and tested it on android and it is working fine there.
I've summarised your code which appears to boil down to:
I've added it to the demo app and its working fine.
The android build problem you are having seems odd. Almost like you have corrupt cache.
bsutton commentedon Jul 2, 2020
I've just logged into the /r/flutterdev discord server. Is that where you are?
bsutton commentedon Jul 2, 2020
https://discord.gg/Y2Ax7p
bsutton commentedon Aug 9, 2020
Closing as I believe this is resolved in the latest beta.