The JavaScript moust videoplayer Cordova plugin allows videos to play in a Cordova (PhoneGap) hybrid-app html/css/js environment in Android. Unfortunately, it stretches/squeezes the video to play it according to the device screen’s proportion. Can you modify this code so the video plays back according to its own proportion? I tried to make it fit a div carefully dimensioned, but it breaks out of the div and plays fullscreen.
This is the full external JS code:
var exec = require("cordova/exec");
module.exports = {
DEFAULT_OPTIONS: {
volume: 1.0,
scalingMode: 1
},
SCALING_MODE: {
SCALE_TO_FIT: 1,
SCALE_TO_FIT_WITH_CROPPING: 2
},
play: function (path, options, successCallback, errorCallback) {
options = this.merge(this.DEFAULT_OPTIONS, options);
exec(successCallback, errorCallback, "VideoPlayer", "play", [path, options]);
},
close: function (successCallback, errorCallback) {
exec(successCallback, errorCallback, "VideoPlayer", "close", []);
},
merge: function () {
var obj = {};
Array.prototype.slice.call(arguments).forEach(function(source) {
for (var prop in source) {
obj[prop] = source[prop];
}
});
return obj;
}
};
This is how it is implemented:
<body>
<div style="margin: 20px;">
<button onclick="playMP4()">PLAY MP4 VIDEO</button>
</div>
<script>
function playMP4() {
VideoPlayer.play(
"file:///android_asset/www/videos/myvideo-h264.mp4",
{
volume: 1.0,
scalingMode: VideoPlayer.SCALING_MODE.SCALE_TO_FIT_WITH_CROPPING
},
function () {
console.log("video completed");
},
function (err) {
console.log(err);
}
);
}
</script>
<script type="text/javascript" src="js/videoplayer.js"></script>
</body>
</html>