HillsideHoldings / cordova-lock-screen-media-controls

A Cordova plugin that allows you to manage the media controls on the lock screen. Things such as play, pause, fast forward, rewind, title and graphic.
0 stars 0 forks source link

Using a local file for the lockscreen imageUrl #1

Open MichaelApproved opened 8 years ago

MichaelApproved commented 8 years ago

Currently, the image works with http:// public URLs. I'm working on a podcast app which needs to work offline, so I cache normal URLs and use local files when I can. Is it possible for the lockscreen to accept a local file as the image? This is an example of a local file URL that I would be using. file:///data/data/com.keithandthegirl.ionic/files/downloads/disposable/showName/1/org-92a8e7188a7b43d3ff066d6299d908c0-cover.jpg

I tried to use that but it didn't work. Is there something in the code that you can edit to allow for this type of URL?

Thanks.

MichaelApproved commented 8 years ago

Note: I had a mistake in the previous message and title. I was referring to the lockscreen metadata image property but I referenced it as "imageUrl" instead of the proper name of "image".

Nick-R commented 8 years ago

@MichaelApproved iOS code can use local URL for this, i think it doesn't work because of wrong path or something like this. Can you send JS testing code which does cache and uses plugin with local URL so i could check?

MichaelApproved commented 8 years ago

@Nick-R iOS is a lot friendlier with the webview. Android has the webview on lock-down. They don't allow anything as an img src to use file://, so I have to save the file to disk as a dataurl and read that back as the img src. It's nuts.

An alternative to that is to include a web server proxy which will allow me to put something like http://localhost:999/the-image.jpg as the img src and then the local web proxy will serve the contents. I avoided doing that because it's one more chunk of code to maintain and one more chunk of code that can break.

Nick-R commented 8 years ago

@MichaelApproved web-proxy should work without a problem. But if you want, i can investigate your js code, probably i'll be able to figure out relative URL to cached image so native iOS code could find it. I'll need to see your js code for that.

alienslab02 commented 8 years ago

This is done in android lock screen plugin already. I have added logic to how to show a file from local storage on lock screen in demo app (android branch). https://github.com/HillsideHoldings/cordova-plugin-demo-app/tree/android

The problem is actually you have to change the image path (if it is local) into proper URL that can be done using File API of cordova. http://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/index.html

Please check it.