Giter Club home page Giter Club logo

Comments (5)

lovegaoshi avatar lovegaoshi commented on July 3, 2024

https://github.com/birkir/react-native-carplay

from azusa-player-mobile.

lovegaoshi avatar lovegaoshi commented on July 3, 2024

Sean Pearson has a fully functional android auto example app set up at: https://github.com/sean-pearson/React-Native-Car-Audio . even though they're integrating this to RNTP I do think we need customized playlist support (which unfortunately is outside of RNTP), so we need to fiddle with whats in the example app in some way shape or form.

from azusa-player-mobile.

lovegaoshi avatar lovegaoshi commented on July 3, 2024

heres what ive found for aa.

  1. aa support for rntp was discussed A WHILE back. both in rntp's discussions and here. TLDR it doesnt work.
  2. the reason it doesnt work is because AA requires a musicservice to extend mediabrowserservicecompat, while rntp has to extend HeadlessJsTaskService. there is no way to extend 2 classes and its been a dead end.

with that said we have several options:

  1. using sean pearson's implementation and use 2 services individually. Or even, share the mediasession token somehow between these two services and we can achieve synchronized play this way. else, 2 services with no syncrhonization is the easiest to do; else we can do a very weird synchronization because we manage playlists outside of rntp, we can manage playback sorta without it either. i can foresee huge performance loss though.
  2. maybe android doesnt care if our service is a mediabrowserservicecompat and only call the getsessiontoken and setsessiontoken? this is quite a slim chance but if true, we can just change kotlinAudio to return the mediasession token, and set the musicservice in RNTP to have a mediabrowserservicecompat intent. i was. tying this last night but gradle ignores my mavenLocal directory. To be fair if i just declare the intent I will have my app in aa's dashboard, but clicking it just shows a loading activityindicator. bad, bad windows 10....
  3. HeadlessJsTaskService and mediabrowserservicecompat all inherits Service anyways. why not fork react-native and make a headlessJsMediaService that extends mediabrowserservicecompat but implement whatever headlessjs does? it will be a giant mess but better than me coming up with a rntp from scratch, or completely switch over to native code.

from azusa-player-mobile.

lovegaoshi avatar lovegaoshi commented on July 3, 2024

can i just shove

    override fun onGetRoot(
            clientPackageName: String,
            clientUid: Int,
            rootHints: Bundle?
    ): MediaBrowserServiceCompat.BrowserRoot {
        return MediaBrowserServiceCompat.BrowserRoot("/", null)
    }

    override fun onLoadChildren(
            parentMediaId: String,
            result: MediaBrowserServiceCompat.Result<List<MediaBrowserCompat.MediaItem>>
    ) {
        //  Browsing not allowed
        if ("MY_EMPTY_MEDIA_ROOT_ID" == parentMediaId) {
            result.sendResult(null)
            return
        }

        // Assume for example that the music catalog is already loaded/cached.

        val mediaItems = emptyList<MediaBrowserCompat.MediaItem>()

        // Check if this is the root menu:
        if (MY_MEDIA_ROOT_ID == parentMediaId) {
            // Build the MediaItem objects for the top level,
            // and put them in the mediaItems list...
        } else {
            // Examine the passed parentMediaId to see which submenu we're at,
            // and put the children of that menu in the mediaItems list...
        }
        result.sendResult(mediaItems)
    }

into musicService.kt and turn this into a musicBrowserService? meanwhile putting copying HeadlessJsTaskService.java into RNTP did not receive complaints, neither is putting musicBrowserService in front of it it seems like. but how is mediaSession actually shared?

it seems like most of the musicService functionalities are handled by KotlinAudio's BaseAudioPlayer.kt. eg. the mediaSession and notificationManager. seems like KA needs to return the mediaSession.sessionToken and musicBrowserService returns the token to other musciBrowserControllers?

from azusa-player-mobile.

lovegaoshi avatar lovegaoshi commented on July 3, 2024

implement android auto to RNTP via extending headlessJsService to MediaBrowserService
both are inheriting Service so I thought its posible;
the problem is RNTP's MusicService overrides binder/onBind as specified here
https://developer.android.com/guide/components/bound-services
and the bound MusicService is accessed in MusicModule.kt.
However this is not possible with MediaBrowserService as seen in
https://stackoverflow.com/questions/50100364/how-to-access-instance-of-mediabrowserservicecompat-service
One should do as
https://medium.com/@ianhlake/dont-try-to-access-the-mediaplayer-directly-in-your-ui-or-create-another-binding-59ad690ab81
This took a week to figure out! Ouch.

from azusa-player-mobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.