【问题标题】:Cordova Video Orientation issue androidCordova视频方向问题android
【发布时间】:2016-11-24 11:12:51
【问题描述】:

我是 cordova 的新手,在 Android 中遇到了 Cordova Camera plugin 的一些问题。

在 Android 中拍摄视频时,以纵向模式捕获并保存视频,但上传后获取的 url 是横向模式:


视频拍摄方法:

Myscript.SocialVideocapture = function(){
var ramv;
var options = {
limit: 1,
duration: 100000000

};

navigator.device.capture.captureVideo(onSuccess, onError, options);

function onSuccess(mediaFiles) {

    VideoEditor.createThumbnail(
    trimSuccess, // success cb
    trimFail, // error cb
    {
    fileUri: mediaFiles[0].fullPath, // the path to the video on the device
    outputFileName: 'output-name', // the file name for the JPEG image
    atTime: 2, // optional, location in the video to create the thumbnail (in seconds)
    width: 320, // optional, width of the thumbnail
    height: 480, // optional, height of the thumbnail
    quality: 100 // optional, quality of the thumbnail (between 1 and 100)
    }
    );

    ramv=mediaFiles[0].fullPath;
    var cvid=Math.floor((Math.random() * 1000000) + 1);
    socialvideosendurl=mediaFiles[0].fullPath;

}

function onError(error) {


} 
}

文件上传方式:

Myscript.Socialsendtoserver = function(event) {



if ($$("#statusbox").val() == '') {
    Appyscript.alert('Please Enter Status', 'Alert!');


} else {

    Appyscript.showIndicator();

    var sfilekey;
    var smimeType;
    var sspath;

    if (socialvideosendurl === undefined || socialvideosendurl === '') {

        sfilekey = "file";
        smimeType = "text/plain";
        sspath = localStorage.getItem("dummysocial");

    } else {

        sfilekey = "video";
        smimeType = "video/quicktime";
        sspath = socialvideosendurl;

    }


    var options = new FileUploadOptions();
    options.fileKey = sfilekey;
    options.fileName = sspath.substr(sspath.lastIndexOf('/') + 1);
    options.mimeType = smimeType;
    var params = new Object();

    options.params = params;
    params.appId = appId;
    params.userId = localStorage.getItem("userid");
    params.status = $$("#statusbox").val();
    params.tag = "myimage";
    params.image = JSON.stringify(sendsoimages);
    params.actionType = "addPost";

    options.params = params;

    options.chunkedMode = false;

    var ft = new FileTransfer();


    ft.upload(sspath, site_url + '/webservices/SocialNetworkPost.php', win, fail, options);


}

}

Original Video File Uploaded

Video File I am getting from server

  • 是服务器端问题还是我的代码中的问题?

【问题讨论】:

    标签: javascript android cordova video cordova-media-plugin


    【解决方案1】:

    我彻底检查了我的代码,发现用于文件上传的 API 正在将视频的方向从纵向更改为横向。

    所以文件上传代码是正确的。

    感谢您考虑这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多