JS APIs for the WVScreen class used in H5 applications and mini programs. These APIs let you get and set the screen orientation (landscape or portrait) and brightness.
WVScreen.getOrientation
Returns the display orientation of the current activity or view controller.
Input parameters
None.
Callback parameters
On success, the success callback is invoked with the parameters below. On failure, the failure callback is invoked.
-
[
string] orientation: The current display orientation. Valid values:'landscape': Landscape.'portrait': Portrait.'unknown': Unknown.
window.WindVane.call('WVScreen', 'getOrientation', {}, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVScreen.setOrientation
Sets the display orientation of the current activity or view controller. Note: This JSBridge affects all pages that the current WebView navigates to after the call — not just the current page. Restore the orientation before navigating away to avoid unintended side effects on subsequent pages.
Input parameters
-
[
string] orientation: The display orientation to set. Valid values:'default': The default orientation of the client.'landscape': Landscape. On iOS, if the client supports it, the orientation automatically switches between left and right landscape based on the device orientation.'portrait': Portrait.'landscapeRight': Landscape right.'landscapeLeft': Landscape left.'portraitUpsideDown': Upside-down portrait.'auto': Automatically switches based on the device orientation.
Callback parameters
On success, the success callback is invoked with no parameters. On failure, the failure callback is invoked.
var params = {
orientation: 'landscape'
};
window.WindVane.call('WVScreen', 'setOrientation', params, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVScreen.setScreenBrightness
This API is available only on WindVane for Android 1.0.3.4 and later.
Sets the screen brightness.
Input parameters
[
number] brightness: The screen brightness level. Must be an integer from 0 (darkest) to 255 (brightest).
Callback parameters
Success callback parameters:
None.
Failure callback parameters:
[
string] msg: An error message describing the failure.
var params = {
brightness: '100'
};
window.WindVane.call('WVScreen', 'setScreenBrightness', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVScreen.getScreenBrightness
This API is available only on WindVane for Android 1.0.3.4 and later.
Returns the current screen brightness.
Input parameters
None.
Callback parameters
On success, the success callback is invoked with the parameters below. On failure, the failure callback is invoked.
[
number] brightness: The current screen brightness level (integer from 0 to 255).
window.WindVane.call('WVScreen', 'getScreenBrightness', {}, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});