Screen orientation change in specific page


#1

Hey everyone,I’m develop an app in ionic, My requirement is play the video in landscape mode. rest of my app in portrait mode . I fix the app into portrait mode by using
it works well. but i want to play video in landscape only. Please help to solve this Issue.

Thanks in advance…


#2

Hi,

have you tried
screen.lockOrientation("landscape");


#3

Hi @whizzkey, Thanks for your reply, I tried with this code, but not worked, if you have any other solution please forward me

Thanks…


#4

How did you fix the app in portrait?


#5

set tag
preference name=“orientation” value="portrait"
in config.xml


#6

I wouldn’t set screen direction in config.xml,

In your inital controller put:
screen.lockOrientation("portrait")

Then when you open your video put:
screen.lockOrientation("landscape")

and when you close your video:
screen.lockOrientation("portrait")


#7

I tried with code, i got an error “screen.lockOrientation is not a function” . If any plugin is required to implement this code. please forward to me. screen is dependency injection or not.


#8

Sorry, I forgot to point out the plugin…


#9

got same error after add plugin


#10

try
window.screen.lockOrientation("portrait")

ios needs this, on android I have not encountered it.


#11

again got same error window.screen.lockOrientation is not a function


#12

In your index.html try and add
<script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="plugins/cordova-plugin-screen-orientation/www/screenorientation.js"></script>

(check if the plugin name is correct).

then try with screen.lockOrientation(…)


#13

add this code in index.html, but not working…


#14

Are you calling it on deviceReady?
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady(){ screen.lockOrientation('landscape'); }


#15

@nani_madepalli

use screen orientation plugin for specific page rotation

and then try this code

$rootScope.$on(’$locationChangeSuccess’, function (event, newUrl, oldUrl) {
try {
if(newUrl.indexOf(’/statename’)>0){
screen.unlockOrientation();
}
else {
screen.lockOrientation(‘portrait’);
}
} catch(ex) { console.log(ex); }

        });

#16

Thanks to @whizzkey,@nitishrajput01 , my problem is solved with screen.lockOrientation(‘landscape’)


#17

Hi I am having the same problem for screen.lockOrientation(‘landscape’); is not a function . I have added this plugin https://github.com/apache/cordova-plugin-screen-orientation.

Android version v6.1.2
Cordova : v6
ionic framework : v1

I am trying this for the last couple of days and i am stuck. I see you have solved the issue. Could you please help me to fix the issue