ryanheise / audio_session

MIT License
107 stars 68 forks source link

getDevices returns empty #89

Closed sunilguptasg closed 1 year ago

sunilguptasg commented 1 year ago

Even the sample app, as it is, returns no devices. Tested on web.

[√] Flutter (Channel stable, 3.7.9, on Microsoft Windows [Version 10.0.19045.2846], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.4)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.77.3)
[√] VS Code, 64-bit edition (version 1.64.0)
[√] Connected device (3 available)
[√] HTTP Host Availability

Please help!

ryanheise commented 1 year ago

That's because this plugin provides functionally specifically for Android and iOS.

sunilguptasg commented 1 year ago

Hi, on pub.dev this has been marked "Android, IOS, MacOS, Web" - can you please get this fixed at it saves so much time!

ryanheise commented 1 year ago

The first paragraph of the README clearly explains that this plugin provides two wrapper classes for iOS (AVAudioSession) and Android (AudioManager). The fact that you see "Web" and "MacOS" listed on the pub.dev page doesn't mean anything needs to be fixed, this is intended. Although this plugin is completely useless in a Web app or a MacOS app, people still need to be able to cross compile their app to different platforms (even if for some of those platforms, some features are not available). So to summarise, this plugin is completely useless for Web and MacOS but can still be included in your common code base for other platforms even if it doesn't have any use on those other platforms. Nobody wants to have to edit their pubspec.yaml just to cross compile for each individual platform.

sunilguptasg commented 1 year ago

Thanks for your detailed answer. And thanks for contributing code! Something I am still to do...

I beg to differ - the pub.dev page should list only platforms that the code works on - not just compiles on. Notes can be added that non-supported platforms support compile with no functionality.

Request you to reconsider your approach to listing supported platforms - I build first for one platform and then test for others in Flutter, and go by the tags to decide which package to use or to clearly understand that I will need others/build my own for others.

And one does not need to edit pubspec.yaml for cross compilation. There are ways to do it - I have different files for web, windows and devices - and never edit pubspec.yaml.

ryanheise commented 1 year ago

I will NOT be removing web support from this plugin, because just_audio depends on it.

The core methods of this plugin will route to the platform-specific capabilities "where available" and will otherwise default to no-ops where the platform either doesn't offer those capabilities or it is unimplemented. just_audio depends on this no-op behaviour of audio_session to handle phone call interruptions on platforms that have such a thing, and to do nothing on platforms that don't have such a thing.

Rather than arguing that I remove web no-ops that just_audio depends on, the productive thing to do would be to contribute code for any feature that you believe should not be a no-op on web.