Last Updated on : 2022-02-16 09:53:06download
This topic describes the API methods encapsulated for IP camera (IPC) panels to implement video features.
For more information, see GitHub Template.
This template is developed based on React Hooks. The app version 3.22 and later are supported for debugging and previewing.
import { TYIpcNative } from '@tuya/tuya-panel-ipc-sdk';
TYIpcNative.enterPlayBack();
TYIpcNative.enterAlbum();
Field | Description | Minimum App SDK version |
---|---|---|
startPlay | Starts playback. | 3.17 |
pausePlay | Pause playback | 3.17 |
iosSnapShootToPhoneAlbums | Saves a snapshot to the album of an iPhone. | 3.17 |
isMuting | Specifies whether to mute the video. | 3.17 |
isRecording | Indicates whether recording is in progress. | 3.17 |
isTalkBacking | Specifies whether to enable video talk. | 3.17 |
isHDOn | Specifies whether to enable the high-definition (HD) video quality. | 3.17 |
enableHd | Specifies whether to enable switching between the HD and standard-definition (SD) video streams. This method only applies to HD and SD video quality. | 3.17 |
changeClarityAndAudio | Supports multiple types of video streams and audio modes, which depend on the specific devices. | 3.17 |
enableMute | Switches between audio modes. | 3.17 |
snapShoot | Enables or disables the video screenshot feature. | 3.17 |
enableRecord | Starts or stops video recording. | 3.17 |
enableStartTalk | Starts one-way or two-way video talk. | 3.17 |
enableStopTalk | Stops one-way or two-way video talk. | 3.17 |
isSupportedCloudStorage | Indicates whether a device supports cloud storage. | 3.17 |
showToast | Shows toast components on native apps. | 3.17 |
enterPlayBack | Opens the common native playback page. | 3.17 |
enterParamPlayBack | Opens the common native playback page with parameters regarding the theme and fixed time point. | 3.20 |
enterAlbum | Opens the common native album page. | 3.17 |
enterParamAlbum | Opens the common native album page with parameters regarding the theme. | 3.20 |
enterCloudBack | Opens the common native cloud storage page. | 3.17 |
enterParamCloudBack | Opens the common native cloud storage page with parameters regarding the theme and fixed time point. | 3.20 |
enterMessageAll | Opens the common native message center page. | 3.17 |
enterParamMessageAll | Opens the common native message center page with parameters regarding the theme. | 3.20 |
enterMediaPlayerPreview | Navigates to the previews of messages, images, and audio. | 3.17 |
enterCameraSetting | Opens the native setting page. | 3.17 |
setScreenOrientation | Switches between screen orientations. | 3.17 |
backPlayPreview | Exits the video preview page. | 3.17 |
enterRnPage | Navigates from the video preview page to level-1 React Native (RN) pages. | 3.17 |
backNavigatorLivePlay | The button used to return to the video preview page from RN pages. | 3.17 |
backLivePlayWillUnmount | Returns to the video preview page from RN pages. Then, the RN pages will be destroyed. Otherwise, the preview page will be frozen. | 3.17 |
getWifiSignal | Returns the Wi-Fi signal strength that ranges from 0 to 100. | 3.17 |
isMobileNetType | Indicates whether a mobile phone is playing video by using mobile data or in other ways, such as broadband or Wi-Fi network. This method is used to indicate network traffic consumption. | 3.17 |
gotoHybridContainer | Navigates to a fixed H5 mobile HTML page. | 3.17 |
backFromActivityBrowser | Listens for returning from the H5 mobile HTML page. | 3.17 |
enterDeviceParamAlbum | Navigates from a dashboard camera to the local album. | 3.22 |
openFloatWindow | Opens a floating window to play videos. | 3.36 |
Minimum app version
3.17
Description
Starts playback.
Request parameters
param: isWirless, privateMode, deviceOnline, clarityStatus, voiceStatus, hightScaleMode, channelNum
-1
.These parameters follow the settings of the player parameters.
Return result
null
Example
TYIpcNative.startPlay(false, false, true, 'HD', true, -1).then(data => {
const { success } = data;
});
Minimum app version
3.17
Description
Pause playback
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.pausePlay().then(data => {
const { success } = data;
});
Minimum app version
3.17
Description
Saves a snapshot to the album of an iPhone.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.iosSnapShootToPhoneAlbums().then(data => {
const { success, imageSrc } = data;
setState({
imageSrc // The thumbnail Base64 data.
})
});
Minimum app version
3.17
Description
Specifies whether to mute the video.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isMuting().then(data => {
const { isMuting } = data;
this.setState({
isMuting,
})
});
Minimum app version
3.17
Description
Indicates whether recording is in progress.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isRecording().then(data => {
const { isRecording } = data;
this.setState({
isRecording,
})
});
Minimum app version
3.17
Description
Specifies whether to enable video talk.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isTalkBacking().then(data => {
const { isTalkBacking } = data;
this.setState({
isTalkBacking,
})
});
Minimum app version
3.17
Description
Specifies whether to enable video talk.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isHDOn().then(data => {
const { isHDOn } = data;
this.setState({
isHDOn,
})
});
Minimum app version
3.17
Description
Specifies whether to enable switching between the HD and SD video streams. This method only applies to HD and SD video quality.
Request parameters
param: HD
| SD
Return result
The Promise
object.
Example
TYIpcNative.enableHd('HD').then(data => {
const { success } = data;
if (success) {
TYIpcNative.showToast('Video stream switch successfully');
} else {
TYIpcNative.showToast('Video stream switching failed');
}
});
Minimum app version
3.17
Description
Supports multiple types of video streams and audio modes, which depend on the specific devices.
Request parameters
param: SS
| SD
| HD
| UD
| SSP
| AUDIO
SS
: saved streams
SD
: standard definition
HD
: high definition
UD
: ultra high definition
SSP
: super ultra HD
AUDIO
: audio
Return result
The Promise
object.
Example
TYIpcNative.changeClarityAndAudio('AUDIO').then(data => {
const { success } = data;
if (!success) {
TYIpcNative.showToast('Audio mode switch failed');
} else {
TYIpcNative.showToast('Audio mode switch successfully');
}
});
Minimum app version
3.17
Description
Switches between audio modes.
Request parameters
param: ON
| OFF
Return result
The Promise
object.
Example
TYIpcNative.enableMute('ON').then(data => {
const { success } = data;
if (success) {
TYIpcNative.showToast('Sound switch successfully');
} else {
TYIpcNative.showToast('Sound switching failed');
}
});
Minimum app version
3.17
Description
Enables or disables the video screenshot feature.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.snapShoot().then(data => {
const { success } = data;
if (success) {
console.log(data.imageSrc, 'Ios is Base64, Android is local path');
} else {
TYIpcNative.showToast('Screenshot failed');
}
});
Minimum app version
3.17
Description
Starts or stops video recording.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.enableRecord().then(data => {
const { success, isRecording, isSaveErr } = data;
if (isRecording && success) {
TYIpcNative.showToast('Recording');
} else if (!success && isSaveErr) {
// Indicates save error
TYIpcNative.showToast('Save err');
} else if (!success && !isSaveErr) {
// Indicates an enable error
TYIpcNative.showToast('operation failed');
} else {
TYIpcNative.showToast('The video has been saved in the album');
}
});
Minimum app version
3.17
Description
Starts the one-way or two-way video talk. During the one-way video talk, the audio mode is OFF
. At the end of the talk, the audio mode is ON
. During the two-way video talk, the audio mode is always ON
.
Request parameters
param: true | false (Specifies whether the two-way video talk is enabled.)
Return result
void
Example
// Returns the talk mode and indicates whether the talk is in progress by using the callback function `onChangeSupportedMicWay onListenIsTalking` of the `TYIpcPlayer` component.
const { isTwoWayTalk, isTalking } = this.props;
if (!isTalking) {
TYIpcNative.enableStartTalk(isTwoWayTalk);
}
Minimum app version
3.17
Description
Stops one-way or two-way video talk. At the end of the one-way video talk, the audio mode is ON
. During the two-way video talk, the audio mode is always ON
.
Request parameters
param: true | false (Specifies whether the two-way video talk is enabled.)
Return result
void
Example
// Returns the talk mode and indicates whether the talk is in progress by using the callback function `onChangeSupportedMicWay onListenIsTalking` of the `TYIpcPlayer` component.
const { isTwoWayTalk, isTalking } = this.props;
if (isTalking) {
TYIpcNative.enableStopTalk(isTwoWayTalk);
}
Minimum app version
3.17
Description
Indicates whether a device supports cloud storage.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isSupportedCloudStorage().then(data => {
const { isSupported } = data;
if (isSupported) {
console.log('Support cloud storage');
} else {
console.log('Does not support cloud storage');
}
})
Minimum app version
3.17
Description
Shows toast components on native apps.
Request parameters
param: string
Return result
void
Example
TYIpcNative.showToast('Anything you want to show');
Minimum app version
3.17
Description
Opens the common native playback page.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterPlayBack();
Minimum app version
3.20
Description
Opens the native playback page with parameters. The dark and light native playback pages are supported. The time
parameter can be set (unit: seconds). The fixed time point for playback can be set in the format of {theme: number, time: 1599791519}
.
theme
: the theme. Valid values: 1
to mean the dark theme, and 2
to mean the light theme. Default value: 1
.
time
: the start timestamp. If this parameter is not set, video footage for the current date is played from the beginning.
Request parameters
param: { theme?: number, time?: number }
Return result
void
Example
TYIpcNative.enterParamPlayBack({ theme: 2, time: 1599791519 });
Minimum app version
3.17
Description
Opens the common native album page.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterAlbum();
Minimum app version
3.20
Description
Opens the native album page with parameters. Dark and light themes are supported.
theme
: the theme. Valid values: 1
to mean the dark theme, and 2
to mean the light theme. This parameter is required.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterParamAlbum({ theme: 2 });
Minimum app version
3.17
Description
Opens the common native cloud storage page.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterCloudBack();
Minimum app version
3.20
Description
Opens the cloud-stored video playback page with parameters. The dark and light native playback pages are supported. The time
parameter can be set (unit: seconds). The fixed time point for playback can be set in the format of {theme: number, time: 1599791519}
.
theme
: the theme. Valid values: 1
to mean the dark theme, and 2
to mean the light theme. Default value: 1
.
time
: the start timestamp. If this parameter is not set, video footage for the current date is played from the beginning.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterParamCloudBack({ theme: 2 });
Minimum app version
3.17
Description
Opens the common native message center page.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterMessageAll();
Minimum app version
3.17
Description
Opens the native message center page with parameters. Dark and light themes are supported.
theme
: the theme. Valid values: 1
to mean the dark theme, and 2
to mean the light theme. Default value: 1
.
Request parameters
param: { theme: number }
Return result
void
Example
TYIpcNative.enterParamMessageAll({ theme: 2 });
Minimum app version
3.17
Description
Opens the native page to preview audio, images, and video.
Request parameters
param: {
devId: deviceId,
msgId: msgSrcId (Message ID),
msgTitle: the message title that can be customized
msgTime: the displayed message time (string),
type: 0
(Video) | 1
(Audio) | 2
(Image),
mediaUrl: the URL of the video, audio, or image
}
Return result
void
Example
TYIpcNative.enterMediaPlayerPreview(param);
Minimum app version
3.17
Description
Opens the native settings page. You can contact the project manager to set the theme.
Request parameters
param: null
Return result
void
Example
TYIpcNative.enterCameraSetting();
Minimum app version
3.17
Description
Switches between screen orientations. Lock the fullscreen state by using the callback function onChangeScreenOrientation
of the TYIpcPlayer
component. isFullScreen
in TYIpcPlayer
is returned to indicate whether the fullscreen state is used.
Request parameters
param: 0 | 1. 0
: portrait screen. 1
: landscape screen.
Return result
void
Example
// Landscape screen
TYIpcNative.setScreenOrientation(1);
// Portrait screen
TYIpcNative.setScreenOrientation(0);
Minimum app version
3.17
Description
Exits the video preview page. It is not used in most cases and has been used internally by TYIpcPlayer
.
Request parameters
param: true | null. true
: exits the video preview page. In this case, peer-to-peer (P2P) connections are closed.
Return result
void
Example
// Disconnect P2P connection
TYIpcNative.backPlayPreview(true);
// Keep P2P connection
TYIpcNative.backPlayPreview();
Minimum app version
3.17
Description
Navigates from the video preview page to level-1 React Native pages. This method is required.
Request parameters
param: (id: string, data: Object)
Return result
void
Example
TYIpcNative.enterRnPage('rnPage', {attr1: value1, attr2: value2});
Minimum app version
3.17
Description
The button used to return to the video preview page from RN pages.
Request parameters
param: null
Return result
void
Example
TYIpcNative.backNavigatorLivePlay();
Minimum app version
3.17
Description
Returns to the video preview page from RN pages. Then, the RN pages will be destroyed. Otherwise, the preview page will be frozen.
Request parameters
param: null
Return result
void
Example
componentWillUnmount() {
TYIpcNative.backLivePlayWillUnmount();
}
Minimum app version
3.17
Description
Returns the Wi-Fi signal strength that ranges from 0 to 100.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.getWifiSignal().then(data => {
const { signalValue } = data;
console.log('signalValue', `${signalValue}%`);
});
Minimum app version
3.17
Description
Indicates whether a mobile phone is playing video by using mobile data or in other ways, such as broadband or Wi-Fi network. This method is used to indicate network traffic consumption.
Request parameters
param: null
Return result
The Promise
object.
Example
TYIpcNative.isMobileNetType().then(data => {
const { isMobileNetWork } = data;
if(isMobileNetWork) {
console.log("You are currently using data playback");
}
});
Minimum app version
3.17
Description
Navigates to a fixed H5 mobile HTML page.
Request parameters
param: h5Url
Return result
void
Example
TYIpcNative.gotoHybridContainer(h5Url);
Minimum app version
3.17
Description
Listens for returning from the H5 mobile HTML page.
Request parameters
param: null
Return result
void
Example
import { TYSdk } from 'tuya-panel-kit';
const TYEvent = TYSdk.event;
componentDidMount() {
TYEvent.on('backFromActivityBrowser', () => {});
}
componentwillUnMount() {
TYEvent.off('backFromActivityBrowser');
}
Minimum app version
3.22
Description
Navigates from a dashboard camera to the local album.
theme
: the theme. Valid values: 1
to mean the dark theme, and 2
to mean the light theme. Default value: 1
.
albumName
: the local album name.
Request parameters
param: { theme? : number, albumName: “ipc_emergency_record” }
Return result
void
Example
TYIpcNative.enterDeviceParamAlbum(param);
Minimum app version
3.36
Description
Opens a floating window to play videos. For non-IPC devices, after the requested result is returned, an API request must be made to close the panel.
Request parameters
null
Return result
Promise<{ success: boolean; err?: any }>
Example
import { TYIpcNative } from '@tuya/tuya-panel-ipc-sdk';
import { TYSdk } from 'tuya-panel-kit';
TYIpcNative.openFloatWindow().then((res) => {
if (res.success) {
TYSdk.native.back();
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback