-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Microsoft Windows ? #103
Comments
Some of my research notes on the subject. We could make FFI bindings to: |
I may attempt this. Musikcore supports gapless playback, so it looks like a good fit. It's also written in C++, so if FFI bindings are done right, we could share the code between Windows and Linux (and even macOS, if it's better than AVPlayer). |
I've looked at Musikcube / Musikcore a little more - the core is completely undocumented, but there's a plugin system. There exists a documented plugin that exposes a web server to interface with the core. It shouldn't be too hard to modify the server to use Flutter platform channels instead of HTTP, and then all the plugin documentation will apply. https://github.com/clangen/musikcube/wiki/remote-api-documentation If we were to uses Musikcore, that leaves two choices:
|
The Musikcore license still looks complicated to me since the individual decoders have separate license agreements (including the GPL). It's also not clear to me what the codec support is for each platform target. ExoPlayer is mentioned, for example, but ExoPlayer taps into hardware decoders that are available on device via the Android SDK, so I would probably expect to see a different set of codecs supported for each platform. |
That's difficult, then. Unfortunately, there aren't many high-level C/C++ Windows audio libraries out there... |
@chuoichien @ryanheise I made a little project here. It can play audio files on Windows 10 & Linux now. I'm ready to help add support for Windows to your this project, if you say. (I'm not pro however 😅). I used miniaudio because it was only audio library with MIT license (even though it wasn't high level & initially I used closed source junk irrKlang). Right now it supports MP3, FLAC & WAV. For supporting more formats, I think I can write something using FFmpeg to convert audio stream to MP3 before playback. I'm using MethodChannel instead of dart::ffi (even though I first used dart::ffi), but main problem came out that one still had to compile different dynamic libraries & change path while loading in Flutter project. But using MethodChannel makes installation simple as to just adding in pubspec.yaml. @hacker1024, C++ libraries I agree aren't super user friendly, some are closed source, some are not openly licensed & some are too low level. Thankyou @ryanheise 💝! |
@alexmercerind great! Perhaps the way to go is to use the federated plugin model. I wasn't really a fan of this model for my plugins since I had intended to write all of the platform implementations myself and I thought it would be a maintenance burden to have a separate plugin for each implementation and keep them in sync. However, I believe this model may actually be a potential solution to our license issue. The LGPL is basically incompatible with iOS because iOS doesn't provide a way for users to install their own version of a DLL. There are ways you could get close by having a separate app to hold the LGPL code and then use IPC between the two apps, but as far as I can see the same developer needs to own both apps, so the user couldn't substitute the LGPL one and have the non-LGPL one use it. Android might be a bit more flexible with IPC but still it's not convenient for most users to have to install the LGPL'd component as a separate app. However, Windows and Linux don't have this restriction with DLLs, so in theory we could have the Windows and Linux implementations have different sets of licenses, which will be easier to manage in the federated model. |
😃 Thankyou for your reply! I'm understanding the situation & your problem with the management of the plugin right now. Right now, in my plugin... I just wanted to help (if I can)... & sorry if any of my knowledge is incorrect. (I'm just 17. I'm learning everything by reading the documentation online) 😄 |
Just to be sure we're on the same page, section 6a of the LGPL reads:
If any app developer uses ffmpeg in their app, then they must comply with this license, and this makes it difficult to "legally" distribute an app on the app store or play store where section 6a can't be fulfilled. That is why I do not accept any LGPL-licensed code in just_audio. But, this issue only exists for mobile apps. Since we're talking about Windows and Linux, it is possible to meet Section 6a of the LGPL, so there is no problem using an LGPL'd library. The federated plugin model makes it possible to keep the LGPL'd portion separate from the rest of the plugin so that the license files can be separate for each part. You can read about federated plugins here: https://flutter.dev/docs/development/packages-and-plugins/developing-packages |
Great! It's good thing that we can separate licenses in federated plugin model. 😁 I just came to know that miniaudio already supports OGG aswell. Possibly we might not need LGPL'd FFmpeg. |
I've just had a look at miniaudio and I'm really impressed. Even though it has limited decoder support, I might use this for some other projects just for the mp3 decoder. I didn't see OGG mentioned in the README. |
I'm not too familiar with the federated plugin architecture, but would it be possible to write two decoding implementations, each in their own federated plugin that connects to the windows implementation plugin? One could use FFmpeg with the appropriate license, and the other could be a thin implementation that lets miniaudio do the decoding. This way, users could choose whichever suits their needs. Abstracting the decoding would also make it easier to switch to something with a better license later, if needed. (I need AAC, and I think it's a fairly popular codec for music streaming services.) |
My understanding is that the app developer could choose one implementation among perhaps multiple alternatives. E.g. they could choose an FFmpeg implemention over another one. I am not sure what you mean by "federated plugin that connects to the windows implementation plugin" in that I don't think alternative implementations would talk to each other and you would only link one of them, but each implementation would link to the platform interface. |
@ryanheise I just noticed that you made a seprate dart file for the web platform. Can I do the same or embed the code in the original just_audio.dart (Making separate file will be easy for me) ? I'm forking your project today & make a good PR soon, as Windows alpha support just came in. |
Hi @alexmercerind , going forward the plan would be to use the federated plugin model mentioned above, so it wouldn't be a separate dart file as is the case for the web platform. But, you can try to get the windows implementation working in any which way, and then integration can wait until we sort out the federated plugin issue. I'll try to have a crack at it on the weekend. |
👋 @ryanheise, All I did right now is add basic functionality (You can see your table in README). Adding things like changing playback speed, clipping, looping, playing from assets shouldn't be hard. I also changed the name of methods channel to match yours. Ideally, it would've been great if Flutter team used C# in Windows like they are doing Java in Android etc. If it was C# I could help a lot more in terms of functionality (I still will) ... but they are using C++ for both Linux & Windows. And writing C++ isn't the most friendly thing when libraries are not great & native APIs look like this (I have no idea of this difficult mess). 😟 FFmpeg is hard... It's very basic right now. |
Ah I forgot to say... Don't forget to save the miniaudio.h in the desktop folder of my fork before trying. Rest should go well for now. |
Well done, @alexmercerind ! You can probably request c# support to the Flutter team (although it probably still won't make FFmpeg any easier to use ;-) Is there an issue with checking the |
@ryanheise, 😃 |
I had forgotten how large that file is :-) I guess it is more like a library. What is the convention for adding dependencies in Windows and Linux plugins? Can it be tied into the build script in some way to automatically download the dependencies? |
@ryanheise As in, a structure like this, where the developer can choose the decoder plugin:
|
I feel like that would contradict
Downloading a source from another place would mean the plugin could break at any time, and it's out of This seems to almost violate this part, too:
|
Oh, when you push the package to the pub.dev just remove the There is not any specific way of adding the dependencies... I modified the CMakeLists to use the I'm not pro in any of C++ or Dart. Just doing my stuff. |
@hacker1024 hmm, this is exactly the way that build scripts for Android and iOS/macOS work. If you depend on a large library like ExoPlayer, you do not embed the library into your git repo, you add the download URL in the build script so that it can be downloaded and cached. So I guess the question I'm asking is, what is the equivalent of this for Linux and Windows? It would not make sense to embed these large 3rd party libraries directly into every pub package. |
I suppose if |
Right, but ExoPlayer and its own dependencies all come from the same place. It's unlikely that ExoPlayer's dependencies will go down. If you could upload the single file to |
Hello everyone! I have made some progress on the Windows version on @libwinmedia's fork (https://github.com/libwinmedia/just_audio). All the essential features (play, pause, seek, volume, speed and playlist) are supported. Here's the Feature list compared to the other platforms:
@alexmercerind, thanks for building libwinmedia, used on the windows version. @ryanheise Do you think this would fit in a PR? |
Awesome, @bdlukaa ! Would someone who has Windows like to test this? In terms of a PR, the beauty of the federated plugin model is that you don't need my approval, you can hold just the windows implementation in a separate repository and publish it as a separate package so long as it conforms to the just_audio platform interface (and ideally follows some package naming conventions that we agreed on above -- |
@ryanheise good to hear! I will publish and maintain the windows plugin, and whenever I do some changes I'll do a PR upgrading the just_audio_windows version. Sounds good? |
Sounds good, just note the package name as mentioned above (since we will possibly have multiple different windows implementations based on different native libraries), and also if maintaining a separate package, your git repository only needs to contain the windows implementation since your |
Okay! I am thinking of adding the Linux (and UWP support in the future) support too, since libwinmedia supports Linux as well! |
libwinmedia already supports Windows & Linux itself, and there is no big deal in it. Infact, I just wrapped WebKit GTK instance to play media (ON LINUX ONLY), so essentially its just a
libwinmedia is mainly a C++ library, and I had to create a basic Flutter package (FFI bindings) to power Harmonoid. A simple package can be enough (with no native code) or just use existing audio_service Apart from So, I'll be glad if Why I was just tired of libVLC's large size & other options being either too weak or just very strictly licensed. Thus, I created my own C++ library. Linux implementation can be made to use Why not You can yourself use
Features list Most features mentioned in that list are already supported by WinRT APIs (and a lot more), its just that I didn't expose them all. P.S. there really needs to be some discussions tab or discord to talk about |
Windows support is now published with features and instructions listed in the README. All credit goes to @bdlukaa for the federated plugin implementation and @alexmercerind for I'll leave this issue open for a bit and so please post below if you encounter any serious issues. Once immediate issues are resolved, I'll close this issue and just_audio_libwinmedia can be used to report any future issues. |
I have tested it on my production app and it works as good as it should! |
I tried my best to implement all the features. Here's the features that can't be supported on Windows at all:
Here are the options that are supported by Windows, but aren't implemented yet:
Effects
|
Nice, it looks like there's a lot of potential, and it's good to know that Some of those features you mentioned like caching and byte streams are currently handled in the Dart layer so shouldn't those work already? In both cases, just_audio sets up a proxy web server to implement the features, and then instead of getting the platform side of the plugin to play the original URL, it passes the proxy URL instead. |
I didn't know that. So you're saying that byte streams should be working? |
Yes, I would have expected this to work. One way to test it could be the caching example which uses a stream audio source under the hood, and that should activate the local proxy on all platforms except web. |
Hello everyone! As you all know, While I was on my days off, I worked on a fully native implementation for windows that is working. Check it out on If you'd like to try it, you can add it as a dependency to your project. No extra setups required: dependencies:
just_audio_windows:
git:
url: https://github.com/bdlukaa/just_audio.git
path: just_audio_windows/ Note that this is an early version with only a few features (most important ones) implemented, but |
I like the direction of this - I noticed it doesn't have a license yet, is that decided? I'll just mention again that since I'm on Linux it is something I will need to rely on others to test. From here, let's get some people trying out just_audio_windows. If it works for testers, let's publish it and get it advertised in the just_audio README where it will have more eyes to detect more bugs and help reach maturity. Once it reaches maturity, we can start looking at the endorsement process which should include some quality assurance that is consistent with the Flutter Favorites programme. A key requirement I would have is to ensure that semantic versioning, as interpreted by pub.dev, is observed. This should guarantee that an update to just_audio_windows doesn't cause just_audio to break its own Flutter Favorite obligations via its transitive dependencies. |
@ryanheise cool! I'll be looking forward to implement all the missing features and fix bugs. I'll let you know when it gets in beta <3 |
@ryanheise Hello! Next step is to impement playlists, documentated here. just_audio_windows uses UWP's native LMK your toughts on endorsing the windows implementation once fully implementated. In case anyone wants to try it, add the following to your dependencies:
just_audio:
git: https://github.com/bdlukaa/just_audio.git |
Awesome! Can people using Windows test this and let @bdlukaa know how it goes? Of course I'd be happy to endorse it once it becomes stable, and in the meantime I should definitely update the README with instructions on how to use it by adding the explicit dependency. |
This is great news, that only leaves us with Linux :) For Linux, I've wanted to make a GStreamer package for a while but never got around to it, and I doubt it could be endorsed due to GStreamer's LGPL license (unless it doesn't really count since you wouldn't statically compile GStreamer?) |
Actually I don't know if there really is a problem endorsing a federated plugin implementation for Linux licenced under the LGPL. An LGPL library does not require the package linking that library to itself become LGPL The issue with LGPL for Flutter apps has specifically been the dynamic linking clause which is incompatible with the iOS and Android app stores. However, when building for those platforms, the Linux implementation would not be linked anyway. If I am wrong about that, it is no big hassle to simply provide instructions in the just_audio README for how to manually add an extra dependency for the Linux implementation. I actually prefer this over endorsement because it's really not too difficult an imposition on the app developer to add one line to their |
Hi @UnicornsOnLSD , have you seen the latest comments on #332 regarding GStreamer? Let's discuss over in that thread. |
@bdlukaa Ii am updating the main README to point to this new Windows plugin. Since your plugin is now in beta, would you consider publishing the beta on pub.dev using appropriate semantic versioning for a beta prerelease? |
Sure! https://pub.dev/packages/just_audio_windows. To use it, just add it to your dependencies: dependencies:
just_audio:
just_audio_windows: |
Hi everyone! I'm glad to announce that |
Awesome! @chengyuhui out of curiosity, is it gapless? Regarding |
I will try to look into the iOS implementation to see how this can be done, though I don't really speak Objective-C :) |
Sorry, is this plugin support microsoft windows ?
The text was updated successfully, but these errors were encountered: