Reputation: 43
What is the right approach to dynamically set the src
attribute of a video element in a Meteor Cordova app? I am trying to capture a video and show it to the user.
I am using Meteor and Cordova for iOS application. I capture the video first using Cordova media capture plugin and then try to display the video for playing using the HTML5 video tag on iOS Meteor Cordova app.
Problem is that when I use <video>
element and specify src
to be a file from application or tmp folder, the video just does not play.
I tried the cdvfile://...
, file:///...
and /var/mobile/...
and none of them work. I also tried calling load and play function after setting the src and that too does not work.
I noticed that some earlier versions of Cordova had this issue (https://issues.apache.org/jira/browse/CB-6051) but it was supposed to be fixed now. What kind of URL would work?
Upvotes: 2
Views: 341
Reputation: 43
So the problem turned out to be not with Cordova but a combination of Cordova and a framework like Meteor. (See : https://issues.apache.org/jira/browse/CB-6051). Meteor serves content at http meteor.local while cordova by itself uses file. Since meteor uses http: to serve the app and local files are at file:, it is considered cross domain access which is restricted. Since plain Cordova uses file to serve application and local files are also at file:, it just works.
The solution I used(from above link) is to use following plugin to serve local files on http protocol, thus circumventing the access issues when mixing protocols on page. When local storage files are served this way, the video tag is able to load video from there (in meteor+cordova apps)
https://github.com/floatinghotpot/cordova-httpd
Upvotes: 1