ionic-cache-src
ionic-cache-src copied to clipboard
Problems with dynamic source
Hi, I have a problem with using dynamic source. My app's idea is to go to firebase and retrieve an array of links of videos, and play the videos one by one like a playlist. Using ionic-cache-src, even if the device is offline, videos can still be played (the links are stored in local storage when they are retrieved from firebase, so even if it's in offline state, the links are still available) Now the problem is, when I test the app in a web browser, everything works well as expected even when the device is offline. But when I try to deploy on a device, the videos can't be loaded when it's offline.
<video autoplay ui-event="{ended:'next()'}">
<source cache-src="{{link}}" type="video/mp4">
</video>
One more thing, when the "{{link}}" part is changed to the actual url of the video, it works perfectly. Thanks for help!
@calcal12 I came across this issue today, and I'd actually say it's not an issue with this plugin (and shouldn't be dealt with here either).
As you know, the scoped variable hasn't been assign by the time the directive runs, so the solution to this problem is to apply an ng-if="link"
on your video tag, that way, your element wont be placed on the dom until your link is assigned.
Replace all instances of scope.$watch('attrs.cacheSrc',
with attrs.$observe('cacheSrc',
in the js file.
@antonfire PR?
@scripter-co see PR https://github.com/BenBBear/ionic-cache-src/pull/21
Has this issue been solved yet? I'm having problems with dynamic URLs (running Android 6) as well. I tried both scope.$watch
and attrs.$observe
versions. When hardcoding the URL into cache-src it's working fine. The URL I'm trying to cache-src is stored in my Firebase. Thanks you!
Hi @FredeHo attrs.$observe works, can you provide a url? If stored in firebase do you mean the url is stored in firebase or a base64 string is stored in firebase? If url please provide an example and I'll see if I can help.
Hi @antonfire, yes the URL is stored in the Firebase (its actually a url to a image stored in Firebase Storage). I also found the solution: It seems the URL is already encoded, so it only worked with encode-uri="false
. Thank you :)