使用Ionic / ngCordova将相机/屏幕方向锁定为横向 [英] Lock camera / screen orientation to landscape with Ionic / ngCordova

查看:836
本文介绍了使用Ionic / ngCordova将相机/屏幕方向锁定为横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在应用程式中将相机方向锁定为纵向,并在相机中横向。

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

对于相机存取,我使用 $ cordovaCapture pluggin。
对于方向 cordova插件屏幕方向

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

两个插件都可以工作,但定向插件不会影响摄像头。
(在Android中测试)

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
        });
};

使用该代码,应用程序方向锁定为纵向,当captureVideo()调用一些ms可以感觉到被锁定到风景,然后相机被打开,你可以录制视频的横向和纵向。然后,再次在应用程序中,方向再次锁定到肖像。

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.

捕获插件没有更多的选项,所以我认为也许是不可能的现在与Ionic。我对吗?任何想法如何获得我想要的?

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?

推荐答案

这是一个错误!我想有人应该更改插件以添加界面的属性。

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"
};

这篇关于使用Ionic / ngCordova将相机/屏幕方向锁定为横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆