florent37 / Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
https://pub.dartlang.org/packages/assets_audio_player
Apache License 2.0
739 stars 336 forks source link

Handle `noNetwork` conditions #214

Closed pro100svitlo closed 4 years ago

pro100svitlo commented 4 years ago

Right now if I turn on example app without internet (flight mode) and click Online track - it freezes the app, which is not nice. Also when it happens, the player throws PlatformException, and it's not usable after it...

So, here I have a few propositions:

florent37 commented 4 years ago

Can you try to implement that ? I do not have much time for now to implement this

pro100svitlo commented 4 years ago

I can try to take a look, but I have 0 experience with library development :)

sumitkakshapati commented 4 years ago

222

florent37 commented 4 years ago

I started on #224

florent37 commented 4 years ago

for now I have

enum AssetsAudioPlayerErrorType {
  Network,
  Player
}
florent37 commented 4 years ago

Player is like unknownError

florent37 commented 4 years ago

It's not finished yet

florent37 commented 4 years ago

it's available, you can try the 2.0.5

look at readme :

_player.onErrorDo = (handler){
  handler.player.stop();
};

and in the handler you have an error that has an attribut type that can be Network :)

sumitkakshapati commented 4 years ago

i hav tried the new update. its awesome. i tried to use this update for my issue #187 . it solve the problem mostly. but choosing action to pause when internet connection goes off and when net comes online choosing play action still doesn't play the music from that point. as new handler give all the necessary thing to reopen the play from exact same point but reopening it in that reason will reset everything and progess bar shown in ui will goes to 0 and than suddenly moves to that point. idk if it can be fixed or not.

pro100svitlo commented 4 years ago

It works as expected when you open audio, it plays for some time, and then network gone 👍

But if I will try open network audio when there is no connection, it still froze the app 😢
Tested on example app.

sumitkakshapati commented 4 years ago

@pro100svitlo for that we can check in flutter only. There are many package which help to check network connection. If network is not available we can stop the user from calling that method and show approriate message from flutter only.

pro100svitlo commented 4 years ago

@Timus23 Yes, you are right. But there still might be cases, when package will return you that network fine, but in fact, there are no transmission. In those cases that package will be useless.

sumitkakshapati commented 4 years ago

yea there are some cases. when i tried to open network songs without internet. it simply freezes the app and when i enable the network. it start playing music automatically and unfreezes the app. In that case the error handling didn't work.

pro100svitlo commented 4 years ago

I still think that this handling should be done internally, cos there pretty much cases:

I all those cases if the audio is not cached and needs a network - the app will be frozen