ryanheise / audio_service

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

Is there carplay support in iOS? #969

Open ghost opened 1 year ago

ghost commented 1 year ago

Documentation request for the following page(s)

https://pub.dev/packages/audio_service

Suggested improvement

Is there carplay support in iOS? As mentioned in the Readme section but when I run the app from the example folder it app gets crashes in carplay (added entitlement) there are no methods related to CPTemplateApplicationSceneDelegate. There is no proper documentation for carplay in iOS.

I tried this flutter_crplay but it doesn't support the Now playing feature.

Is the audio_service pkg support Now playing feature? if it does plz update the documentation with the steps.

Thanks.!!!

ryanheise commented 1 year ago

This plugin does support now playing via the mediaItem stream. Add items to that stream and they show up in now playing. It does not however support any features that are exclusive to carplay. That's something that should definitely be added at some point in the future since audio_service has all of the other related APIs although for now there are other flutter packages that serve this specific purpose.

Contributions are welcome.

keaganhilliard commented 1 year ago

There is a fork of Flutter CarPlay that has the NowPlaying feature built out waiting on the PR to be Merged in. The issue with AudioService handling CarPlay is we might have to create predefined templates that are built out from the getChildren call. I'm not sure though.

ryanheise commented 1 year ago

I wouldn't necessarily want to shoehorn CarPlay into the android Auto API, I think the audio_service platform interface should ideally bu changed to reflect the capabilities of all platforms it supports, so there is no problem to adding more methods.

So to proceed on this, it would be useful to map out the different features, see where there is an alignment with Android Auto, and see where there is not (and where new APIs need to be introduced into the interface).

keaganhilliard commented 1 year ago

The large part of CarPlay is GenericTemplates that can be rendered. Which doesn't quite align to what audio_service has done historically (other than maybe notifications on Android).

The Relevant ones: TabBar, Grid, List, Alert, Dialog, ActionSheet, NowPlaying, Information

But these are all UI elements... So maybe it makes sense to just offload CarPlay to another library that can handle all of the rendering.

I have this implemented in my app and it works ok, there are definite issues, but it's generally workable. The main issue plagueing it is waking up the Flutter engine doesn't seem to work correctly.

It might be enough to make an example project that walks devs through connecting audio_service and flutter_carplay.

ryanheise commented 1 year ago

You may be right. If it can exist as a separate plugin, then it should. In the case of Android Auto, it is not an easily separable API so that's really a reflection of the Android API design.

However, in the case of Now Playing, is it the case that you could use flutter_carplay just to render the Now Playing state, but use audio_service to set the Now Playing info via MPNowPlayingInfoCenter?

keaganhilliard commented 1 year ago

Actually I believe that's how my app is currently working. I only build the MediaItem templates and flutter_carplay hadles creating the shared NowPlayingInfo template. I didn't have to manually handle really anything on that end for it to work. The problem is that you have to use a fork that has the shared NowPlaying instance currently. Another issue is that upon adopting the CarPlay scene delegate stuff, audio_service can't handle the NowPlaying view anymore, not a problem if you the updated for because you get it back, but with the current version it doesn't work correctly.

ghost commented 1 year ago

@keaganhilliard can u please share your demo code with us for car play with audio_service pkg. we have added audio_service pkg as a path in our flutter project, but facing an issue in carplay. Thanks for the above suggestions

keaganhilliard commented 1 year ago

I don't really have an example app as my app is fairly complicated at this point. I just followed the directions that flutter_carplay has in their docs and it all worked for me. I would suggest that you double check that you correctly followed all of the directions. Also if there's an issue with CarPlay it's probably worth creating an issue on the flutter_carplay repo or asking a question on stack overflow.

This repo has the NowPlaying feature implemented: https://github.com/icapps/flutter_carplay/tree/combine-all

ryanheise commented 1 year ago

@Subhangi3 I agree it would be quite a good idea to have a reference example showing how these two projects can fit together, but these things also require volunteers. Perhaps if you are going through the process of following the tutorials, you might be interested in contributing such an example?

If it requires anything disruptive to enable bitcode, then I can create a separate subdirectory to hold this carplay specific example and eventually link it from the audio_service README.