ionic-cache-src icon indicating copy to clipboard operation
ionic-cache-src copied to clipboard

Problems with dynamic source

Open calvinkei opened this issue 8 years ago • 7 comments

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!

calvinkei avatar Mar 30 '16 09:03 calvinkei

@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.

scripter-co avatar Apr 07 '16 19:04 scripter-co

Replace all instances of scope.$watch('attrs.cacheSrc', with attrs.$observe('cacheSrc', in the js file.

antonfire avatar Apr 08 '16 13:04 antonfire

@antonfire PR?

scripter-co avatar Apr 10 '16 03:04 scripter-co

@scripter-co see PR https://github.com/BenBBear/ionic-cache-src/pull/21

antonfire avatar Apr 10 '16 18:04 antonfire

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!

FredeHo avatar Aug 05 '16 14:08 FredeHo

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.

antonfire avatar Aug 05 '16 14:08 antonfire

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 :)

FredeHo avatar Aug 09 '16 09:08 FredeHo