Lock camera / screen orientation to landscape with Ionic / ngCordova

与世无争的帅哥 提交于 2019-12-25 04:45:15

问题


I am trying to lock camera orientation to portrait in the app and to landscape in the camera.

For camera access I am using $cordovaCapture pluggin. For orientation cordova-plugin-screen-orientation.

Both plugins work but orientation plugin doesn't affect camera. (Testing in an Android)

screen.lockOrientation('portrait');

$scope.captureVideo = function() {
    var options = { 
        limit: 1, 
        duration: 15
    };

    screen.lockOrientation('landscape');
    $cordovaCapture.captureVideo(options)
        .then(function(videoData) {
            screen.lockOrientation('portrait');
            //Whatever
        });
};

With that code, app orientation is locked to portrait, when captureVideo() is call for some ms you can feel that is locked to landscape, then camera is opened and you can record video both landscape and portrait. Then, again in the app, orientation is lock again to portrait.

Capture plugin doesn't have more options so I think maybe is not possible right now with Ionic. Am I right? Any idea how to get what I want?


回答1:


It's a bug! I think someone should change the plugin to add the property of the interface.

var options = { 
    limit: 1, 
    duration: 15,
    orientation: "landscapeLeft"
};


来源:https://stackoverflow.com/questions/31558337/lock-camera-screen-orientation-to-landscape-with-ionic-ngcordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!