ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
787 stars 463 forks source link

Using justAudio instead of audioPlayer in example #109

Closed mohammadne closed 4 years ago

mohammadne commented 4 years ago

Hi ryanheise . excuse me but for some reasons I have to work with audioplayers instead of audioplayer . for example for isLocal and ... . it works well with audioplayer but when I want to use it with audioplayers ,

RaisedButton audioPlayerButton() =>
      startButton('AudioPlayer', _audioPlayerTaskEntrypoint);

doesn't work .

also I think it worth to update your example with audioplayers for someones like me . Thanks very much ryanheise

ryanheise commented 4 years ago

Hi @mohammadne

Currently audioplayers indeed does not seem to work with audio_service. I recently contacted the author to get a PR accepted that would address one issue, and he merged that one, although things broke again in the latest release and I haven't heard back from him yet on that one.

Looking through the audioplayers code, there appear to be some recent overlapping concerns between the two plugins rather than a clear separating line which could present problems in the future. This is unfortunate, because I would also really love to use audioplayers, and it can't happen if it's incompatible.

Generally the plugins that should cooperate well with audio_service are those plugins that just play audio and don't attempt to carry any additional responsibilities that overlap with what audio_service does, or at least provide the option to switch those responsibilities off. I have heard that flutter_radio works, and of course the original audioplayer works.

Out of curiosity, what are the additional features of audioplayers that you need?

I am considering building my own audio player plugin that is guaranteed to maintain compatibility with audio_service while also making it possible to build all the ultimate features we want in an audio player. So if you tell me what features would go into your ideal audio player, I may see what I can do.

mohammadne commented 4 years ago

It's Great to hear that you are considering to build your own player. Features of audioplayers are recommended like play audio in 3 mode, seek, volume of sound, audio rate and... . Also more customizable notification is sth very good for example background color based on the image of song. Also Adding equalizer and frequency filtering is very good feature which I haven't seen yet.

ryanheise commented 4 years ago

The background features are already provided by audio_service, such as the background colour changing based on the image of the song. I like all of the features you listed, but can you clarify what you mean by "3 mode"?

ivmilicevic commented 4 years ago

Not OP but long time follower. I think @mohammadne is talking about 3 different sources of audio that audioplayers plugin supports: remote file(network), local file and file from project assets

mohammadne commented 4 years ago

Yes, excuse me if I don't super clear about that:

There are three possible sources of audio: 1-Remote file on the Internet 2-Local file on the user's device 3-Local asset from your Flutter project

ryanheise commented 4 years ago

@mohammadne , @ivmilicevic , thanks for the clarification. Sounds good to me.

hamidne commented 4 years ago

maybe a fork of audioPlayers is a good idea 🧡

ryanheise commented 4 years ago

I was initially thinking of making a fork of audioplayers, but after looking through its copyright history, ownership and license isn't as clear as you might hope, across both audioplayers and even the original audioplayer. There are a number of technical things I would have done differently anyway if I were to design an audio player plugin from scratch, so for a number of reasons, including legal, technical and maintainability, I'm biting the bullet and making a fresh plugin.

Yesterday, I actually started building it, and today I finished the Android side. Will publish after I come back from lunch.

ryanheise commented 4 years ago

OK, just published version 0.0.1 of a new plugin called just_audio:

https://pub.dev/packages/just_audio

Let me know how it goes. If there are any urgent missing features, I can add them, though my priority would otherwise be to implement the iOS side.

ryanheise commented 4 years ago

FYI, the iOS implementation is coming along.

I'm using a MacInCloud plan which gives me 3 hours of development time per day. So, yesterday I spent 3 hours just before midnight, and then another 3 hours just after midnight giving me effectively a 6 hour stretch :-) . Have to wait until midnight tonight for another 3 hour stretch during which I hope to get to the code complete -> testing/debugging stage.

ryanheise commented 4 years ago

Just published version 0.0.2 which includes an iOS implementation. I can say that it compiles and I can say that it runs, but what I cannot say is whether you'll hear any audio. I'm effectively doing this development deaf because I haven't figured out how to link the MacInCloud audio to my local computer's audio card.

However, all indications seem to suggest that something is happening when I hit play. It shows a spinner while loading the track, for example, and it detects the end of track and stops. However, seeking behaviour does not appear to be as intended. According to the logs, the seek is completing immediately rather than waiting a few moments to buffer, so you don't see the spinner appear, which it should. If I could hear it, I would expect the audio to be momentarily interrupted while it's seeking, and perhaps I just need to figure out how to actually detect that so that I can indicate a buffering state.

I did implement all of the Android features except for the untilPosition parameter of play which will just require me to do a little more iOS research.

hamidne commented 4 years ago

very Awesome .

IrosTheBeggar commented 4 years ago

Hi @ryanheise,

I'm a developer working on a music streaming app in Flutter. I built the original version with the audioPlayers library, and I've been following this project looking for a good time to implement the audio_service plugin.

It sounds like you need a mac computer to properly develop this project. I have an old iMac desktop that I use to automate OSX builds for mStream. I could send it to you since to help with development. If you're interest, email me at paul@mstream.io and we'll figure out how to get it too you.

ryanheise commented 4 years ago

@IrosTheBeggar Are you serious? :astonished: That would be a huge help! And it's amazing to have someone reach out across the Internet in that way. But chances are we also live on opposite sides of the world (I'm based in Australia) which may make things more difficult. I've sent you an email.

mohammadne commented 4 years ago

Hi @ryanheise,

First of all, thanks for your great job. Then I want to know, when you substitute your example with just_audio instead of audioPlayer?

ryanheise commented 4 years ago

Hi @mohammadne That's definitely the plan. Right now, it's a brand new plugin and will need to undergo some testing.

Currently there have been zero bug reports filed which makes me a bit nervous :-) I don't take that to mean that there are zero bugs, I take it to mean that it currently hasn't undergone enough testing ;-) Also, I haven't personally been able to test it on a real iOS device and confirm whether it actually works, although if anyone has tried it, I'd love to hear from you as to whether it worked for you.

ryanheise commented 4 years ago

After going through several rewrites of the just_audio Android implementation, I've finally got it to the point where I'm comfortable using it in my own apps and I have also updated the audio_service example to use it. I "think" the iOS side is working although hopefully iOS users can help me by reporting your experiences.

Thanks everyone for your interest, and to those who have offered support, and from here I would encourage anyone interested in just_audio to star that project, (and maybe add a like on pub.dev if you feel that you do like it, this will probably go into their future search ranking algorithms), and to post any questions and issues over on that project.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.