Cordova external app + local video

前端 未结 2 1534
轻奢々
轻奢々 2021-02-02 17:21

We have an iOS app built with PhoneGap / Cordova 4.3.0. This app directly loads an external website by using in the

2条回答
  •  独厮守ぢ
    2021-02-02 18:01

    In my experience using the file:// protocol has been problematic on iOS because the protocol starts at the root of the device filesystem.

    I don't believe that any Cross-Origin problems are being faced here because Cordova doesn't implement Cross-Origin requests, but rather treats all requests as coming from the origin to which they are requesting. See this answer.

    My theoretical solution is using a relative URL instead of trying to use any protocol at all. However, the way you implement this might depend on when the file is successfully downloaded.

    
    

    Where cdvfile://localhost/www/ was the path you set for the target argument when you called fileTransfer.download() referenced here.

    It may be necessary to either create the video element or set the video src in javascript once the successCallback has fired. Again you would set the src as a relative URL.

    Please note videos will not autoplay on mobile

    From the Safari Developer Library

    In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled.

提交回复
热议问题