Skip to content
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

No Android support? #10

Open
ds8k opened this issue Mar 24, 2015 · 22 comments
Open

No Android support? #10

ds8k opened this issue Mar 24, 2015 · 22 comments
Assignees

Comments

@ds8k
Copy link

ds8k commented Mar 24, 2015

Is this just too hard to accomplish on Android? I've been looking all over for an Android version of this plugin and it simply doesn't exist. What's the deal?

@LukePulverenti
Copy link

It looks dead simple with the new MediaSession class, which is designed to allow you to report media playback to the rest of the system.

https://developer.android.com/reference/android/media/session/MediaSession.html

Although unfortunately that requires api 21.

@greatwitenorth
Copy link

I could use android support as well. Is there any plans to support Android? @ds8k did you end up finding a solution?

@homerours
Copy link
Collaborator

For Android support, you can have a look at cordova-plugin-music-controller. It might however not be perfect...

@shi11
Copy link
Owner

shi11 commented Sep 28, 2015

Nice @homerours. I haven't tested your code but the api seems similar. Want to merge your project into this one to provide folks with a more complete remote controls plugin?

@homerours
Copy link
Collaborator

Yes, that would be a good solution. But maybe it would be better that you update your JS API to make it easier to understand: use object (instead of arrays) for notifications infoos. Also, why do you fire a DOM event instead of running aa user callback?
You can have a look at MusicController.js to see what I mean.

@shi11
Copy link
Owner

shi11 commented Sep 28, 2015

Cool. When you say notification infos, do you mean passing data from js to ios? From examples I've seen, using a array is pretty common. But happy to explore using JSON. I'm down to refactor out the dom event in place of a callback - makes sense.

I'll create a branch and add you as a contributor to the project. We'll work off the branch and go from there. Sound good?

@homerours
Copy link
Collaborator

Sounds good.
About notifications info, I mean that it would be easier for the end-user to pass an object as argument rather than an array (and have to remember "1=song, 2=artist ..."). It would also make the code easier to understand.

@shi11
Copy link
Owner

shi11 commented Sep 28, 2015

Cool I agree.

@shi11
Copy link
Owner

shi11 commented Sep 28, 2015

@pvandrunen
Copy link

@shi11 @homerours This is fantastic! I've installed this branch on my project and it was easy to integrate into my html5 audio player code. I had been using this for iOS and was excited to see the addition for Android and Windows.

I may not be able to help with code commits, but I would love to participate by providing feedback while testing. Is this the best place to provide feedback or should I open new tickets? I'll be testing iOS and Android on a multitude of devices.

On android I notice that there is no event called for when a phone call is coming in or some other app plays audio or should interrupt, such as google earth. Is this even possible?

Thanks for this!

@pvandrunen
Copy link

@homerours I'm running this branch on android. I found that there is a bug, but I don't know how to fix. I am able to get the code running on android devices that I have for testing which are 4.1.2 and 5.0.2 by commenting out the following starting at line 43 on MusicControls.java:

    // Register pendingIntent for broacast
    public void registerMediaButtonEvent(){
        //this.mAudioManager.registerMediaButtonEventReceiver(this.mediaButtonPendingIntent);
    }
    public void unregisterMediaButtonEvent(){
        //this.mAudioManager.unregisterMediaButtonEventReceiver(this.mediaButtonPendingIntent);
    }

@homerours
Copy link
Collaborator

@pvandrunen Thank you very much for this feedback! This fonctions are used to listen to the headset button. It should intercept the click event (that is usually linked to default android music player).
What kind of bug did you experienced when uncommenting those lines? (I'm running the plugin on android 4.4 device and android 5.1 emulator without bugs)
(Sorry for the delay) for your previous message, when a phone call is coming, I notices that android pause all audio listening. When the call is over, everything is running as before. So I think that this behaviour is "acceptable". I don't know if it's possible to detect when other apps starts playing audio, I will investigate it !
Sorry again for the delay

@pvandrunen
Copy link

Thanks for the response. Before uncommenting those lines there was an error
message, which I found in the logs about a class being undefined (I think)
so the API had no effect - the controls would not appear in the
notification area on the decides in had listed. Interestingly the Controls
DID work on android 4.4 but I upgraded that device to 5.0 and the controls
no longer appear.

When I am back at my desk I will send more details.

Phil

On Friday, October 23, 2015, homerours notifications@github.com wrote:

@pvandrunen https://github.com/pvandrunen Thank you very much for this
feedback! This fonctions are used to listen to the headset button. It
should intercept the click event (that is usually linked to default android
music player).
What kind of bug did you experienced when uncommenting those lines? (I'm
running the plugin on android 4.4 device and android 5.1 emulator without
bugs)
(Sorry for the delay) for your previous message, when a phone call is
coming, I notices that android pause all audio listening. When the call is
over, everything is running as before. So I think that this behaviour is
"acceptable". I don't know if it's possible to detect when other apps
starts playing audio, I will investigate it !
Sorry again for the delay


Reply to this email directly or view it on GitHub
#10 (comment)
.

Philip Van Drunen
Journey Multimedia, Inc.
☎ 970-673-7872

@homerours
Copy link
Collaborator

Please try the code at the original repo. The code I pushed on the android branch is a little bit outdated and may cause bugs.

@fran-pb
Copy link

fran-pb commented Jul 7, 2016

any news? is the branch ready to use it or still in development state?

It sounds good to see two developers unite their efforts towards community

@Guichaguri
Copy link

Any plans on the Android support?
If you still want it, I might open a PR with the code to make it work.

@shi11
Copy link
Owner

shi11 commented Sep 1, 2016

Oh cool @Guichaguri yeah that'd be great. I definitely dropped the ball on this but if you wanted to run with it and create a PR that'd be great.

@Guichaguri
Copy link

Guichaguri commented Sep 2, 2016

It's really easy to get it working on Android, but it will need some API changes.
Currently, the API only supports artist, title, album, image, duration and elapsed time. There are a lot of other properties that can be implemented. I was thinking about optional properties, and other ones that are only used on Android or iOS.

Android currently supports: artist, title, album, image, duration, elapsed time, state, volume, speed, buffered position, rating, description, release date, genre, and many other properties

Here is what I was thinking:

window.remoteControls.updateMetadata({
    title: '',
    artist: '',
    album: '',
    cover: '',
    duration: 0,
    rating: 75,
    description: '',
    date: '',
    genre: ''
});

window.remoteControls.updatePlayback({
    elapsedTime: 0,
    bufferedTime: 0,
    volume: 100,
    state: 1, // -1: Error, 0: Stopped, 1: Playing, 2: Paused, 3: Buffering
    speed: 1
});

window.remoteControls.updateActions({
    play: true,
    pause: true,
    stop: false,
    seekTo: false,
    skipToNext: true,
    skipToPrevious: true,
    rate: true,
    volume: true
});

document.addEventListener("remotecontrols", function(event) {
    switch(event.action) {
        case 'play':
        case 'pause':
        case 'stop':
            // Handle basic controls
            break;
        case 'volume':
            // Handle new volume
            //event.volume
            break;
        case 'seek':
            // Handle new playback position
            //event.position
            break;
        case 'next':
        case 'previous':
            // Handle skipping
            break;
        case 'rate':
            // Handle rating
            //event.rating
            break;
    }
});

I don't know which of them are supported by iOS, I only added the most important properties from Android, and also, most of them are optional.
We should still support the old function and event for compatibility purposes.

@shi11 What do you think?

@shi11
Copy link
Owner

shi11 commented Sep 3, 2016

Nice @Guichaguri. I think it looks good. We should research what is supported in iOS. What do other folks think?

@Guichaguri
Copy link

Guichaguri commented Sep 3, 2016

I got it working on Android with the new API. I'll open a PR when I fix and test everything

Tablet Lockscreen
Buttons - Custom Colors

It should work with API 14+ (98.2% of the Android users)

@Guichaguri
Copy link

Done! #32

@mike-nelson
Copy link

What's happened? Can we get that merged? Be keen to use this for Speaking Email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants