shi11 / RemoteControls

cordova 3 plugin for interacting with ios7 remote controls and metadata
57 stars 41 forks source link

Crash on ios8 #2

Closed thtro closed 10 years ago

thtro commented 10 years ago

Hi,

When trying to update the metadata, while playing a media, it crashes the whole app. Also when trying to receive an event, I get the following error "ReferenceError: Can't find variable: remoteControls" . Tested on ios 8 and 7.1

shi11 commented 10 years ago

Hi, are you referencing the plugin as remoteControls or window.plugins.remoteControls? It should be the latter. Made that change a couple weeks ago.

thtro commented 10 years ago

Hi, Thanks for the answer. Yes, I reference the plugin with window.plugins.remoteControls.

shi11 commented 10 years ago

Hi, please give it a try again. The errors were related to setting an image. I've fixed the errors but haven't been able to get the actual image to show up yet.

Also I'm making some changes in the api. You now call it like this:

var params = [artist, name, album, image, elapsedTime ]; window.plugins.remoteControls.updateMetas(function(success){ console.log(success); }, function(fail){ console.log(fail); }, params);

The callbacks aren't working yet either. Nonetheless, I wanted to let you know so that you can integrate it without your project crashing! Let me know how it goes.

thtro commented 10 years ago

Thanks a lot! I will give it a try and let you know. Please let me know if you manage to get the button events working, that's the aspect that I wanted more than the metas. It seems that ios 8 automatically handles the video metas, better than before. Regards

shi11 commented 10 years ago

Hi, button events are working again, as are album art. The only outstanding issue for me now is elapsedTime. Please see the readme. I added some impt lines of code to the MainViewController.m

thtro commented 10 years ago

Hi, Thanks for the fix. Just to be sure I'm using it right, I should listen for the event named "remote-event" on "document" ? What params does it receive? Sorry if it's written somewhere, I can't see it :)

shi11 commented 10 years ago

yup, you got it. i'll add that to the readme.

document.addEventListener("remote-event", function(event) { })

thtro commented 10 years ago

Indeed, it's not crashing, but neither does it seem to work. The metas don't get updated and I don't receive any event. I'm testing on ios 8.1 ipad air on simulator. If you use a device, could you please try the simulator?

Or, if you have a test project that you use and everything works fine for you, maybe post that so that I have a reference? Thanks a lot!

shi11 commented 10 years ago

Ok I tested it in the simulator (both ipad and iphone ios8.1) and can verify that nothing is showing up...hmm...

On Thu, Oct 23, 2014 at 3:36 PM, Andrei notifications@github.com wrote:

Indeed, it's not crashing, but neither does it seem to work. The metas don't get updated and I don't receive any event. I'm testing on ios 8.1 ipad air on simulator. If you use a device, could you please try the simulator?

Or, if you have a test project that you use and everything works fine for you, maybe post that so that I have a reference? Thanks a lot!

— Reply to this email directly or view it on GitHub https://github.com/shi11/RemoteControls/issues/2#issuecomment-60296164.

thtro commented 10 years ago

Probably it's an issue caused by different implementations of the MediaPlayer framework... anyway most probably your plugin is fine, Apple's simulator is not :), don't loose your time with this. Can you please give me an example of the object received as a parameter on the remote-event? I want to hook the "previous" and "next" events into my app, until tomorrow, when I'll get my hands on an iPad.

shi11 commented 10 years ago

ok, lemme know how it goes when on your ipad.

here you go:

document.addEventListener("remote-event", function(event) {
switch(event.remoteEvent.subtype){
                 case "play":
                    togglePlay();
                     break;
                 case "pause":
                     togglePlay();
                     break;
                 case "playpause":
                     togglePlay();
                     break;
                 case "skip":
                     skip();
                     break;
                 case "back":
                     back();
                     break;
             }
})
thtro commented 10 years ago

On my ipad mini, with ios 7, I can't get it working. I'm targeting ios 8, but this is the only iPad I could get my hands on.

document.addEventListener("remote-event", function(event) { console.log("REVENT",event); // it's never called switch(event.remoteEvent.subtype){ } });

I have included the plugin automatically with the CLI command: cordova plugin add https://github.com/shi11/RemoteControls.git and then added the MediaPlayer framework, is it ok?

shi11 commented 10 years ago

hmm, any errors? are you including an image? if the image is missing it will fail. I'm working on making the image optional...

shi11 commented 10 years ago

just updated some more code. on iphone5s/ios8 it's working. but since the simulator isn't working, i can't fully test it...

ghenry22 commented 10 years ago

Perhaps you could post a very simple app that just logs to console for a few actions, I'll be glad to test on ios8 and iphone6 for you in that case.

thtro commented 10 years ago

I managed to get it working. I forgot to add the lines in Main.m, they don't get added when adding the plugin via CLI from github.

Thanks a lot for all the support, have a great weekend!