bsutton / sounds

Flutter plugin for sound. Audio recorder and player.
GNU Lesser General Public License v3.0
78 stars 25 forks source link

[HELP] BackgroundAudioService causing problems with another package #52

Closed kbanta11 closed 3 years ago

kbanta11 commented 4 years ago

I am using the Sounds package primarily for the recorder. I am not using the SoundPlayer (since it requires the file to be completely downloaded before playing, which isn't viable for a podcast app when the download delay could take 10+minutes), but am instead using a different audio player (audioplayers) and audio_service for the notification state. This appears to all be working fine, except for the media buttons in the notification state don't work because both audio_service (correctly) and sounds (incorrectly since I'm not using the player or shade player) are registering to the same media buttons which is causing errors.

Does anyone know how to prevent sounds from registering the background audio service/notification area so I can handle this with the audio_service package?

kbanta11 commented 4 years ago

I've been able to get his working on Android by removing most of the shade player code (trying to strip down to just the recorder but it seems the soundplayer is still required for the recorder to work). This, however, causes the plugin to not be able to build when I try the iOS version (even though I've only removed/edited android and lib code). It leads to this error: ios/Runner/GeneratedPluginRegistrant.m:174:4: Use of undeclared identifier 'Sounds'.

I'm really not sure how to proceed, but this is breaking my project in all ways I've attempted. I either can't build with my edited sounds package for iOS (but works for Android), or I can leave the sounds package untouched, but it then will cause major breaking errors due to sounds assuming that I want to use the shade player and registers the media buttons, which breaks the audio_service package, which is the one I need to use at it works properly (whereas sounds player does not, due to the long delay in waiting for the audio file to completely download before starting, sometimes up to 10 minutes which isn't workable for my use case as I need more on-demand audio streaming (podcast player, no one will wait for 10 minutes before they can start listening to any podcast). Any ideas why I'm getting the undeclared identifier error in iOS? Or is there a better way to keep sounds from trying to register the shade player so it doesn't break audio_service?

Larpoux commented 4 years ago

I am curious to know if the sound that you are trying to play is a remote file or a remote stream

kbanta11 commented 4 years ago

I am trying to play a remote file (either the podcast files from the RSS feed or audio files stored on firebase). When I use the audioplayers plugin, I can start playing files almost immediately, but it doesn't have a notification area feature, so I've paired it with audio_service and am only using sounds for the recorder (since there doesn't appear to be any other good Flutter audio recorder). When I try to play the same podcast episode between audioplayers and sounds, sounds will often take more than a couple of minutes to begin playing whereas audioplayers begins after only a few seconds.

Larpoux commented 4 years ago

I see :-/

One feature which is badly missing on Flutter Sound is the possibility to play from a remote Stream (webRTC). But the current TODO stack is full and not enough contributors

kbanta11 commented 4 years ago

Yeah, that's another feature I'm waiting on, but first am trying to just finish the podcast player portion which is proving a challenge. I'm not sure what audioplayers does differently that allows it to start playing so much quicker, might be worth looking into. I've noticed things beginning to pile up and have been trying to figure out some of these issues on my own, but admittedly, I have basically zero iOS native development experience and only a few years of native Android development. I will look into seeing how I can help though! (though might not be going anywhere fast if I can't figure out how to get it to even build on iOS haha)

Larpoux commented 4 years ago

You can post a "Problem Report" on Flutter Sound, so that someone, one day, maybe, perhaps, will take care of your needs.

This is the best you can do if you want work on that issue. Probably port audioplayers code inside Flutter Sound. But I do not guarantee any delay.

kbanta11 commented 4 years ago

What I really don't get is why iOS gives me the undeclared identifier error for the sounds package, but only after I made changes to my fork of the package. From what I can tell, the sounds class exists, and even if I make no changes to ANY of the iOS code, it still gives me this error, but only if I'm using my forked version. Does anyone have any insight into why xcode would consider Sounds to be undeclared? (or where to start looking)?

Larpoux commented 4 years ago

This is a question for my friend @bsutton 👀

Larpoux commented 4 years ago

re-post

relf108 commented 4 years ago

The most likely scenerio I can think of with you're issues on the forked version of sounds is that we've pushed a breaking iOS change to GitHub and kept the pub package on a (semi) stable version which is what you're using when you're not forking (correct me if I'm wrong). We've been working super hard these past few days in getting out some major changes regarding how we're handling the iOS side of the project and as such haven't had much of a chance to clean up master. That being said, I've got a lot of free time as of a few days ago all of which is going into finishing this major refactoring so stay tuned for that. Once it's done we'll be clearing up all the issues which have come in over the past couple weeks. Thanks so much for your patience and we hope to have this dealt with soon :)

kbanta11 commented 3 years ago

The most likely scenerio I can think of with you're issues on the forked version of sounds is that we've pushed a breaking iOS change to GitHub and kept the pub package on a (semi) stable version which is what you're using when you're not forking (correct me if I'm wrong). We've been working super hard these past few days in getting out some major changes regarding how we're handling the iOS side of the project and as such haven't had much of a chance to clean up master. That being said, I've got a lot of free time as of a few days ago all of which is going into finishing this major refactoring so stay tuned for that. Once it's done we'll be clearing up all the issues which have come in over the past couple weeks. Thanks so much for your patience and we hope to have this dealt with soon :)

Do we have an idea of what the last commit was that worked for iOS to work off of that in my fork? Or an estimate on work needed for FFI to be complete and a new version compatible with iOS to be ready (happy to help with what little I'm able, if there is anything)?

bsutton commented 3 years ago

@kbanta11 Kyle we would love some help with the ffi work particularly if you have an ios background.

I've raised an issue #60 to track what is going on with the ffi conversion. Its still a bit light on so raise questions against that issue and I will try to answer them. I'm a little bogged down with other project for the next couple of weeks so not much will be happening at this end.

bsutton commented 3 years ago

We have delayed the ffi work to get out a 1.0.0 release. The full swift code is on master.