Mini App Document Mini App Document
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • API overview
  • Basics
  • Routing
  • Jump
  • Forwarding
  • Interface
  • Network
  • Data caching
  • Media
    • Pictures
      • saveImageToPhotosAlbum
      • previewMedia
      • previewImage
      • getImageInfo
      • compressImage
      • object.success callback function
      • parameter
      • chooseMessageFile
      • chooseImage
      • fileToBase64
    • Video
      • saveVideoToPhotosAlbum
      • createVideoContext
      • VideoContext method
      • chooseVideo
      • previewVideo
      • VideoContext
    • Audio
      • stopVoice
      • setInnerAudioOption
      • playVoice
      • pauseVoice
      • createInnerAudioContext
      • createAudioContext
      • AudioContext
      • InnerAudioContext
    • Background audio
      • BackgroundAudioManager
    • Live audio and video
      • createLivePusherContext
      • createLivePlayerContext
    • Recording
      • stopRecord
      • startRecord
      • getRecorderManager
      • RecorderManager
    • Camera
      • createCameraContext
      • CameraContext.onCameraFrame
      • parameters
      • function callback
      • parameters
      • Object res
      • Return value
      • CameraFrameListener
      • Sample code
      • CameraContext.setZoom
      • parameters
      • Object object
      • object.success callback function
      • parameters
      • CameraContext.startRecord
      • parameters
      • Object object
      • object.timeoutCallback callback function
      • parameters
      • CameraContext.stopRecord
      • parameters
      • Object object
      • object.success callback function
      • parameters
      • CameraContext.takePhoto
      • parameters
      • Object object
      • object.success callback function
      • parameters
      • CameraFrameListener.start
      • parameters
      • Object object
      • CameraFrameListener.stop
      • parameters
      • Object object
    • Rich text
      • EditorContext.blur
      • EditorContext.clear
      • EditorContext.format
      • EditorContext.getContents
      • EditorContext.getSelectionText
      • EditorContext.insertDivider
      • EditorContext.insertImage
      • EditorContext.insertText
      • EditorContext.redo
      • EditorContext.removeFormat
      • EditorContext.scrollIntoView
      • EditorContext.setContents
      • EditorContext.undo
  • Map
  • Location
  • File
  • Device
  • Canvas
  • FXML
  • Customize the menu
  • Other
  • API
2022-08-09
Directory

Media

# Pictures

# saveImageToPhotosAlbum

Base Library 2.0.7 is supported, iOS version 2.10.7, Android version 2.11.43

saveImageToPhotosAlbum(Object object)

Save the picture to the system album.

Parameters

Object object

Properties Type The default value is Required Description
filePath string Yes Picture file path, which can be a temporary file path or a permanent file path, does not support network picture path
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized the user did not grant permission to read external storage, read and write external storage)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user refuses authorization and returns an error message: unauthorized, the user did not grant the album permission
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for album permissions
  • Interface authorization failed (Android):
  1. The user refuses authorization and returns an error message: The unauthorized user has not granted permission to read external storage, read and write external storage
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# previewMedia

Preview pictures and videos.

Parameters

Object object

Properties Type The default value is Required Description
sources Array.<Object> Yes The list of assets that need to be previewed
current number 0 No The resource sequence number currently displayed is
showmenu boolean true No Whether to display the menu by long press, long press the picture to display the menu to send to friends, favorite, save the picture, search, open the business card / go to the group chat / open the Mini App (if the picture contains the corresponding QR code or Mini App code) menu
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

structure of object.sources

Properties Type The default value is Required Description
url String Yes The address of the image or video
type String image No The type of resource, which defaults to picture
poster string No The cover image of the video

Legal value of type

The value Description Minimum version
image Image
video Video

# previewImage

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

previewImage(Object object)

Preview the picture in full screen on a new page.

Parameters

Object object

Properties Type The default value is Required Description
urls Array.<string> Yes List of link lists of images that need to be previewed
current string The first of urs No The link to the currently displayed picture
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# getImageInfo

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

getImageInfo(Object object)

Gets picture information.

Parameters

Object object

Properties Type The default value is Required Description
src string Yes The path of the picture, which can be relative path, temporary file path, storage file path, network picture path,
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function

Parameters

Object res

Properties Type Description
width number The original width of the image, in px.
height number The original height of the image, in px.
path string The local path of the picture

Sample Code

# compressImage

ft.compressImage(Object object)

Base Library 2.0.5 is supported, iOS version 2.10.4, Android version 2.11.39

Compression image interface, optional compression quality

Parameters

Object object

Properties Type The default value is Required Description
src string Yes Image path, the path of the picture, support local path, code package path
quality number 80 No Compression quality, ranging from 0 to 100, the smaller the value, the lower the quality, the higher the compression rate (valid only for jpg
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)
# object.success callback function
# parameter
Properties Type Description
tempFilePath string The temporary file path (local path) of the compressed picture

Sample Code

# chooseMessageFile

Base Library 1.3.9 StartEd Support, iOS Version 2.1.23 (Not Supported), Android Version 2.1.38 (The "Recently Downloaded" directory will be selected)

Select a file from the file manager.

Parameters

Object object

Properties Type The default value is Required Description
count number true Yes The maximum number of files that can be selected, which can be 0 to 100
type string 'all' No The type of file selected
extension Array.<string> No Filters by file extension and is valid only when type==file. Each item cannot be an empty string. By default, it is not filtered.
camera string 'back' No By default, the front or rear camera is pulled up.
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized user did not grant read and write permissions to the external store)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Valid value for object.type

The value Description
all Select
video Only video files can be selected
image Only picture files can be selected
file You can select files other than pictures and videos

note

  • Interface authorization failed (Android):
  1. The user denies authorization and returns an error message: Unauthorized User did not grant read and write permissions to the external store
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# chooseImage

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

chooseImage(Object object)

Select a picture from a local album or take a photo with your camera.

Parameters

Object object

Properties Type The default value is Required Description
count number 9 No The maximum number of images you can select is
sizeType Array.<string> ['original', 'compressed'] No the size of the selected image
sourceType Array.<string> ['album', 'camera'] No Select the source of the image
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized the user did not grant permission to read external storage, read and write external storage)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Legal value for object.sizeType

The value Description
original Original figure
compressed The compression graph

Valid value for object.sourceType

The value Description
album Select a picture from the album
camera Use the Camera

object.success callback function

Parameters

Object res

Properties Type Description
tempFilePaths Array.<string> the list of local temporary file paths for the picture
tempFiles Array.<Object> local temporary file list for pictures

Structure of res.tempFiles

Properties Type Description
path string The local temporary file path
size number Local temporary file size, in B

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user refuses authorization and returns an error message: unauthorized, the user did not grant the album permission
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for album permissions
  • Interface authorization failed (Android):
  1. The user refuses authorization and returns an error message: The unauthorized user has not granted permission to read external storage, read and write external storage
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# fileToBase64

ft.fileToBase64(Object object)

Images are converted to base64 data

Parameters

Object object

Properties Type The default value is Required Description
url string Yes Picture path, the path of the picture, support local path

object.success callback function

Parameters

Properties Type Description
data string The converted base64 data

Sample Code

# Video

# saveVideoToPhotosAlbum

Base Library 2.0.7 is supported, iOS version 2.10.7, Android version 2.11.43

saveVideoToPhotosAlbum(Object object)

Save the video to the system album. Supports mp4 video formats.

Parameters

Object object

Properties Type The default value is Required Description
filePath string Yes The video file path, which can be a temporary file path or a permanent file path (local path)
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized the user did not grant permission to read external storage, read and write external storage)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user refuses authorization and returns an error message: unauthorized, the user did not grant the album permission
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for album permissions
  • Interface authorization failed (Android):
  1. The user refuses authorization and returns an error message: The unauthorized user has not granted permission to read external storage, read and write external storage
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# createVideoContext

Base Library 2.11.2 Started Support, iOS Version 2.34.1, Android Version 2.34.1 VideoContext ft.createVideoContext(string id, Object this)

Create a video context VideoContext object.

Parameters

string id

The id of the video component

Object this

Under Custom Components, this of the current component instance to manipulate the component within the video component

Return Value

VideoContext

# VideoContext method

VideoContext.play()

Play the video

VideoContext.pause()

Pause the video

VideoContext.stop()

Stop the video

VideoContext.seek(number position)

Jumps to the specified location

position unit s

VideoContext.sendDanmu(Object data)

Send a barrage

Parameters

Object data

Properties Type The default value is Required Description
text string Yes Bullet screen text
color string No Barrage color

VideoContext.playbackRate(number rate)

Set the speed of playback

Multiplier rate, legal value 0.5/0.8/1.0/1.25/1.5/2

VideoContext.requestFullScreen(Object object)

Go to full screen (not supported by the IDE)

Parameters

Object object

Properties Type The default value is Required Description
direction number No Sets the orientation of the video when full screen is not specified, and is automatically judged based on the aspect ratio. Legal values: 0, 90, -90

VideoContext.exitFullScreen()

Exit full screen (not supported by the IDE)

VideoContext.showStatusBar()

Displays the status bar, which is only valid in iOS full screen.

VideoContext.hideStatusBar()

Hides the status bar, which is only valid in iOS full screen.

VideoContext.requestBackgroundPlayback()

Enter background audio playback mode (not supported by the IDE)

VideoContext.exitBackgroundPlayback()

Exit background audio playback mode (not supported by the IDE)

# chooseVideo

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

chooseVideo(Object object)

Select a video from a local album or use your camera to shoot a video.

Parameters

Object object

Properties Type The default value is Required Description
sourceType Array.<string> ['album', 'camera'] No Select the source of the video
compressed boolean true No Whether to compress the selected video file
maxDuration number 60 No The maximum shooting time of shooting video is
camera string 'back' No By default, the front or rear camera is pulled up.
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized user did not grant read external storage permission)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Valid value for object.sourceType

The value Description
album Select a video from the album
camera Use the camera to take a video

Legal value of object.camera

The value Description
back By default, the rear camera
front By default, the front camera

object.success callback function

Parameters

Object res

Properties Type Description
coverImagePath string The preview picture path for the selected video is
duration number The duration of the selected video is
tempFilePath string The temporary file path for the selected video
size number The amount of data for the selected video is
width number The original width of the image, in px.
height number The original height of the image, in px

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user refuses authorization and returns an error message: unauthorized, the user did not grant the album permission
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for album permissions
  • Interface authorization failed (Android):
  1. The user denies authorization and returns an error message: The unauthorized user did not grant permission to read the external store
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# previewVideo

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

previewVideo(Object object)

Preview the video in full screen on a new page.

Parameters

Object object

Properties Type The default value is Required Description
url string Yes The video resource address, which can be a temporary video path or a network video path.
autoplay boolean false No Whether to compress the selected video file
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# VideoContext

VideoContext instance, available via ft.createVideoContext. VideoContext is bound to a video component by id to operate the corresponding video component.

Method

  • VideoContext.play()
    Play the video
  • VideoContext.pause()
    Pause the video
  • VideoContext.stop()
    Stop the video
  • VideoContext.seek(number position)
    Jumps to the specified location
  • VideoContext.sendDanmu(Object data)
    Send a barrage
  • VideoContext.playbackRate(number rate)
    Set the speed of playback
  • VideoContext.requestFullScreen(Object object)
    Go to full screen. If you have custom content that needs to be displayed in full screen, you need to place the content node in the video node.
  • VideoContext.exitFullScreen()
    Exit full screen
  • VideoContext.showStatusBar()
    Displays the status bar, which is only valid in iOS full screen
  • VideoContext.hideStatusBar()
    Hides the status bar, which is only valid in iOS full screen
  • VideoContext.exitPictureInPicture()
    Exit the window, the method can be called on any page

# Audio

# stopVoice

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

stopVoice(Object object)

Ends playing the voice.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# setInnerAudioOption

setInnerAudioOption(Object object) Sets playback options for InnerAudioContext. After setting, it takes effect globally for the current MiniApp.

Parameters

Object object

Properties Type The default value is Required Description
mixWithOther boolean true No Whether to mix with other audio, when set to true, does not terminate the music
obeyMuteSwitch boolean true No (effective only for iOS) If the mute switch is followed, when set to false, the sound can be played even in mute mode
speakerOn boolean true No true means playing with speakers, false for handset playback, and the default value is true.
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Note In order to ensure the overall experience, when speakerOn is true, the client will ignore the content of the mixWithOthers parameter, forcing mutual exclusion with other audio Does not support switching to speaker playback during the playback of audio, developers can first pause the currently played audio and record the currently paused time point, and then switch to restart the audio playback from the original paused time point

# playVoice

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

playVoice(Object object)

Start playing speech while only one voice file is being played, and if the previous voice file has not finished playing, the previous voice playback will be interrupted.

Parameters

Object object

Properties Type The default value is Required Description
filePath string Yes The file path of the voice file that needs to be played is
duration number 60 No Specifies the recording duration, and automatically stops recording after reaching the specified recording duration in
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# pauseVoice

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

pauseVoice(Object object)

Pauses the voice that is playing. When you call ft.playVoice again to play the same file, playback starts from where it was paused.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# createInnerAudioContext

InnerAudioContext ft.createInnerAudioContext()

Create an audio context InnerAudioContext object.

Return Value

InnerAudioContext

# createAudioContext

AudioContext ft.createAudioContext(string id, Object this)

Create an audio context AudioContext object.

Parameters

string id

The id of the audio component

Object this

Under Custom Component, this of the current component instance to manipulate the component within the Audio component

Return Value

AudioContext

# AudioContext

**AudioContext instance, available via ft.createAudioContext. **

AudioContext binds an audio component to an id to operate the corresponding audio component.

Method

  • AudioContext.setSrc(string src)
    Set the audio address
  • AudioContext.play()
    Play audio.
  • AudioContext.pause()
    Pause the audio.
  • AudioContext.seek(number position)
    Jumps to the specified location.

Sample Code

# InnerAudioContext

**InnerAudioContext instance, available via ft. InnerAudioContext fetched. **

Properties

  • string src
    The address of the audio resource for direct playback.
  • number startTime
    The position where playback begins (in units: s), which defaults to 0
  • boolean autoplay
    Whether playback starts automatically, the default is false
  • boolean loop
    Whether to loop playback, the default is false
  • number volume
    Volume. Range 0 to 1. The default is 1
  • number playbackRate
    Playback speed. Range 0.5-2.0, default is 1.

Method

  • InnerAudioContext.play()
    Play
  • InnerAudioContext.pause()
    Time out. Paused audio replay starts playing from where it was paused
  • InnerAudioContext.stop()
    Stop it. When you stop the audio playback, it starts playing from scratch.
  • InnerAudioContext.seek(number position)
    Jumps to the specified location
  • InnerAudioContext.destroy()
    Destroys the current instance
  • InnerAudioContext.onCanplay(function callback)
    Monitor events where audio enters a playable state. However, it is not guaranteed that it will play smoothly later
  • InnerAudioContext.offCanplay(function callback)
    Cancels the event that monitors the audio into a playable state
  • InnerAudioContext.onPlay(function callback)
    Listen for audio playback events
  • InnerAudioContext.offPlay(function callback)
    Cancels the monitoring of audio playback events
  • InnerAudioContext.onPause(function callback)
    Listen for audio pause events
  • InnerAudioContext.offPause(function callback)
    Cancels the monitoring audio pause event
  • InnerAudioContext.onStop(function callback)
    Listen for audio stop events
  • InnerAudioContext.offStop(function callback)
    Cancels monitoring for audio stop events
  • InnerAudioContext.onEnded(function callback)
    Monitor events where the audio naturally plays until the end
  • InnerAudioContext.offEnded(function callback)
    Cancels the monitoring of events where audio is playing naturally until the end
  • InnerAudioContext.onTimeUpdate(function callback)
    Listen for audio playback progress update events
  • InnerAudioContext.offTimeUpdate(function callback)
    Cancels the monitoring of audio playback progress update events
  • InnerAudioContext.onError(function callback)
    Listen for audio playback error events
  • InnerAudioContext.offError(function callback)
    Cancels monitoring for audio playback error events
  • InnerAudioContext.onWaiting(function callback)
    Listen for events in audio loading. Triggers when audio needs to be stopped to load due to insufficient data
  • InnerAudioContext.offWaiting(function callback)
    Cancels monitoring for events in audio loading
  • InnerAudioContext.onSeeking(function callback)
    Monitors events for audio jump operations
  • InnerAudioContext.offSeeking(function callback)
    Cancels the event that monitors the audio for jump operations
  • InnerAudioContext.onSeeked(function callback)
    Monitors events where the audio completes the jump operation
  • InnerAudioContext.offSeeked(function callback)
    Cancels the event that monitors the audio to complete the jump operation

Sample Code

# Background audio

# BackgroundAudioManager

**BackgroundAudioManager instance, available via ft.getBackgroundAudioManager. **

Note: The ability of iOS BackgroundAudioManager to play audio in the background requires the user to add it at target-capabilities, background Modes and check audio, AirPlay, and Picture in Picture

Properties

  • string src
    The data source for the audio. The default is an empty string, when a new src is set, it will automatically start playing, the currently supported formats are m4a, aac, mp3, wav.
  • number startTime
    The position where the audio starts playing in units: s.
  • string title
    Audio title, for native audio player audio title (required). The share function in the native audio player, the card title shared out, will also use this value.
  • string epname
    The album name, the share function in the native audio player, and the card profile shared out will also use this value.
  • string singer
    The singer name, the sharing function in the native audio player, and the card profile shared out will also use this value.
  • string coverImgUrl
    Cover image URL, which is used to make a background image for native audio players. The sharing function in the native audio player, the shared card picture and background will also use the picture.
  • string webUrl
    Page links, sharing features in native audio players, and card profiles shared out will also use this value.
  • string protocol
    Audio protocol. The formats that can be played depend on the system's built-in player.
  • number playbackRate
    Playback speed. Range 0.5-2.0, default is 1. (Android requires version 6 and above)
  • number duration
    The length of the current audio, in units: s, is returned only if there is a valid src. (read-only)
  • number currentTime
    The playback position of the current audio, in units: s, is returned only if there is a legitimate src. (read-only)
  • boolean paused
    Whether it is currently paused or stopped. (read-only)
  • number buffered
    The time the audio has been buffered, only the content from the current playback time point to this point in time is guaranteed to be buffered. (read-only)
  • string referrerPolicy
    Not supported

Method

  • BackgroundAudioManager.play()
    Play
  • BackgroundAudioManager.pause()
    Pause the music
  • BackgroundAudioManager.seek(number currentTime)
    Jumps to the specified location
  • BackgroundAudioManager.stop()
    Stop the music
  • BackgroundAudioManager.onCanplay(function callback)
    Monitor events where audio enters a playable state. However, it is not guaranteed that it will play smoothly later
  • BackgroundAudioManager.onPlay(function callback)
    Listen for audio playback events
  • BackgroundAudioManager.onPause(function callback)
    Listen for audio pause events
  • BackgroundAudioManager.onStop(function callback)
    Listen for audio stop events
  • BackgroundAudioManager.onEnded(function callback)
    Monitor events where the audio naturally plays until the end
  • BackgroundAudioManager.onTimeUpdate(function callback)
    Listen for audio playback progress update events
  • BackgroundAudioManager.onError(function callback)
    Listen for audio playback error events
  • BackgroundAudioManager.onWaiting(function callback)
    Listen for events in audio loading. Triggers when audio needs to be stopped to load due to insufficient data
  • BackgroundAudioManager.onSeeking(function callback)
    Monitors events for audio jump operations
  • BackgroundAudioManager.onSeeked(function callback)
    Monitors events where the audio completes the jump operation
  • BackgroundAudioManager.onNext(function callback)
    Monitor the user tapping the next track event in the system music playback panel (iOS only)
  • BackgroundAudioManager.onPrev(function callback)
    Listening user clicks on the last song event in the system music playback panel (iOS only)

Sample Code

# Live audio and video

# createLivePusherContext

createLivePusherContext()

Create a live-pusher context LivePusherContext object.

Return Value

LivePusherContext

Method

  • LivePusherContext.start(Object object)
    Start streaming while turning on camera preview
  • LivePusherContext.stop(Object object)
    Stop push streaming while stopping the camera preview
  • LivePusherContext.pause(Object object)
    Pause the push stream
  • LivePusherContext.resume(Object object)
    Resume push streaming
  • LivePusherContext.switchCamera(Object object)
    Switch between the front and rear cameras
  • LivePusherContext.snapshot(Object object)
    snapshot
  • LivePusherContext.toggleTorch(Object object)
    Switch the flashlight
  • LivePusherContext.playBGM(Object object)
    Play a background sound
  • LivePusherContext.stopBGM(Object object)
    Stops the background tone
  • LivePusherContext.pauseBGM(Object object)
    Pauses the background tone
  • LivePusherContext.resumeBGM(Object object)
    Restores the background tone
  • LivePusherContext.setBGMVolume(Object object)
    Sets the background tone volume
  • LivePusherContext.setMICVolume(Object object)
    Set the microphone volume
  • LivePusherContext.startPreview(Object object)
    Turn on camera preview
  • LivePusherContext.stopPreview(Object object)
    Turn off camera preview

# createLivePlayerContext

createLivePlayerContext()

Create a live-player context LivePlayerContext object. It is recommended to use ft.createSelectorQuery to get the context object.

Parameters

string id

The id of the live-player component

Object this

Under Custom Components, this of the current component instance to manipulate the component within the live-player component

Return Value

LivePlayerContext

Method

  • LivePlayerContext.play(Object object)
    Play
  • LivePlayerContext.stop(Object object)
    Stop it
  • LivePlayerContext.mute(Object object)
    mute
  • LivePlayerContext.pause(Object object)
    Time out
  • LivePlayerContext.resume(Object object)
    recover
  • LivePlayerContext.requestFullScreen(Object object)
    Go to full screen
  • LivePlayerContext.exitFullScreen(Object object)
    Exit full screen
  • LivePlayerContext.exitPictureInPicture(Object object)
    Exit the window, the method can be called on any page
  • LivePlayerContext.snapshot(Object object)
    Screenshots

# Recording

# stopRecord

Base Library 1.3.9 started support, iOS version 2.1.23, Android version 2.1.38, dependent extension SDK

stopRecord(Object object)

Stop recording.

Sample Code

# startRecord

Base Library 1.3.9 started support, iOS version 2.1.23, Android version 2.1.38, dependent extension SDK

startRecord(Object object)

Start recording. Automatically ends recording when ft.stopRecord is actively invoked, or when recording exceeds 1 minute. This interface cannot be called when the user leaves the MiniApp.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The interface calls the failed callback function (returns an error message when authorization fails: fail unauthorized user did not grant camera, record audio permissions)
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function

Parameters

Object res

Properties Type Description
tempFilePath string The temporary path to the recording file

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user denies authorization and returns an error message: unauthorized, the user has not granted microphone permissions
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for microphone permissions
  • Interface authorization failed (Android):
  1. When the user refuses authorization, an error message is returned: The unauthorized user has not granted the camera and record audio permissions
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications

# getRecorderManager

RecorderManager ft.getRecorderManager()

Gets the globally unique recording manager RecorderManager

Return Value

RecorderManager

# RecorderManager

Globally unique recording manager

Method

  • RecorderManager.start(Object object)
    Start recording

    Parameters

    Object object

    Properties Type The default value is Required Description
    duration number 60000 No The duration of the recording, in ms, maximum 600000 (10 minutes)
    sampleRate number 8000 No Sample rate (pc not supported)
    numberOfChannels number 2 No The number of recording channels is
    encodeBitRate number 48000 No The code rate, valid values are shown in table
    format string aac No Audio format
    format string aac No Audio format
    frameSize number No Specifies the frame size, in KB. After you pass in frameSize, the recorded file content is called back after each time the specified frame size is recorded, and the callback is not called back if it is not specified. Only mp3, pcm formats are supported.
    audioSource string auto No Specifies the frame size, in KB. After you pass in frameSize, the recorded file content is called back after each time the specified frame size is recorded, and the callback is not called back if it is not specified. Only mp3, pcm formats are supported.

    Sample rate and encoding bitrate limits

    **Each sample rate has a corresponding encoding bitrate range valid value, setting an illegal sample rate or encoding bitrate will cause the recording to fail, the specific correspondence is as follows. **

    Sample rate Encoding bitrate
    8000 16000 ~ 48000
    11025 16000 ~ 48000
    12000 24000 ~ 64000
    16000 24000 ~ 96000
    22050 32000 ~ 128000
    24000 32000 ~ 128000
    32000 48000 ~ 192000
    44100 64000 ~ 320000
    48000 64000 ~ 320000

    sampleRate

    The legal value Description
    8000 8000 sample rate
    11025 11025 Sample rate
    16000 16000 Sample rate
    22050 22050 Sample rate
    24000 24000 Sample rate
    32000 32000 Sample rate
    44100 44100 Sample rate
    48000 48000 Sample rate

    numberOfChannels

    The legal value Description
    1 1 channel
    2 2 channels

    format

    The legal value Description
    mp3 mp3 format
    aac aac format
    wav wav format
    PCM pcm format

    audioSource

    The legal value Description
    auto Auto settings, use the phone microphone by default, automatically switch to use the headset microphone after plugging in the headset,
    buildInMic Phone microphone, iOS
    headsetMic Wired headset microphone, iOS
    mic Microphones (phone microphone when headset is not plugged in, headphone microphone when headset is plugged in), Android
    camcorder Same as mic, suitable for recording audio and video content, Android
    voice_communication With MIC, for real-time communication, Android
    voice_recognition Same as mic, for speech recognition, Android
  • RecorderManager.pause()
    Pause the recording

  • RecorderManager.resume()
    Continue recording

  • RecorderManager.stop()
    Stop recording

    Parameters

    Object object

    Properties Type Description
    tempFilePath string The temporary path (local path) of the recording file
    duration number Total recording duration in ms
    fileSize number Recording file size in Byte
  • RecorderManager.onStart(function callback)
    Monitor recordings to start events

  • RecorderManager.onResume(function callback)
    Monitor recordings to continue events

  • RecorderManager.onPause(function callback)
    Monitor recording pause events

  • RecorderManager.onStop(function callback)
    Monitor recording end events

  • RecorderManager.onError(function callback)
    Listen for recording error events

  • RecorderManager.onInterruptionBegin(function callback)
    The listening recording was interrupted because it was occupied by the system. The pause event fires after this event

  • RecorderManager.onInterruptionEnd(function callback)
    Monitor recording interrupt end event. After receiving the interruptionBegin event, all recordings in the Mini App are paused, and only after receiving this event can the recording be successfully recorded again.

Sample Code

note

  • Interface Authorization Failed (iOS):
  1. The user denies authorization and returns an error message: unauthorized, the user has not granted microphone permissions
  2. The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for microphone permissions

# Camera

# createCameraContext

createCameraContext()

Create a camera context CameraContext object.

Return Value

CameraContext

# CameraContext.onCameraFrame

CameraFrameListener CameraContext.onCameraFrame(function callback)

Gets the Camera live frame data

# parameters

# function callback

Callback function

# parameters

# Object res

Properties Type Description
width number The width of the image data rectangle
height number The height of the image data rectangle
data ArrayBuffer Image pixel data, a one-dimensional array of rgba

# Return value

# CameraFrameListener

Note: To use this interface, you also specify frame-size in the camera component properties.

# Sample code

# CameraContext.setZoom

CameraContext.setZoom(Object object)

Sets the zoom level

# parameters

# Object object

Properties Type The default value is Required Description
zoom number Yes Zoom level, range[1, maxZoom]. zoom can take decimal places, accurate to the next decimal place. maxZoom is available in the bindinitdone return value.
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# object.success callback function

# parameters

Properties Type Description
zoom number The zoom level that is actually set. Due to system limitations, some models may not be able to set to the specified value and will instead use the nearest settable value.

# CameraContext.startRecord

CameraContext.startRecord(Object object)

Start recording

# parameters

# Object object

Properties Type The default value is Required Description Minimum version
timeoutCallback function No Recording ends when it is over 30s or when the page is onHide
<!-- timeout number 30 No Maximum recording time 2.22.0 -->
<!-- selfieMirror boolean true No whether mirroring is turned on 2.22.0 -->
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# object.timeoutCallback callback function

# parameters

Properties Type Description
tempThumbPath string The temporary path (local path) of the cover picture file
tempVideoPath string The temporary path (local path) of the video file

# CameraContext.stopRecord

CameraContext.stopRecord(Object object)

End the recording

# parameters

# Object object

Properties Type The default value is Required Description
compressed boolean false No Start video compression, which is the same as the chooseVideo
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# object.success callback function

# parameters

Properties Type Description
tempThumbPath string The temporary path (local path) of the cover picture file
tempVideoPath string The temporary path (local path) of the video file

# CameraContext.takePhoto

CameraContext.takePhoto(Object object)

Take a photo

# parameters

# Object object

Properties Type The default value is Required Description Minimum version
quality string normal No Image quality, high/normal/low
<!-- selfieMirror boolean true No whether mirroring -->
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# object.success callback function

# parameters

Properties Type Description
tempImagePath string The temporary path (local path) of the photo file, Android is the jpg image format, ios is the png

# CameraFrameListener.start

CameraFrameListener.start(Object object)

Start listening for frame data

# parameters

# Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# CameraFrameListener.stop

CameraFrameListener.stop(Object object)

Stop listening for frame data

# parameters

# Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# Rich text

# EditorContext.blur

EditorContext.blur(Object object)

The editor loses focus while the keyboard is folded.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.clear

EditorContext.clear(Object object)

Empty the editor contents

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.format

EditorContext.format(string name, string value)

Modify the style

Parameters

string name

attribute

string value

value

List of styles supported by setting

Properties The value
bold
italic
underline
strike
ins
script sub / super
header H1 / H2 / h3 / H4 / h5 / H6
align left / center / right / justify
direction rtl
indent -1 / +1
list ordered / bullet / check
color hex color
backgroundColor hex color
margin/marginTop/marginBottom/marginLeft/marginRight css style
padding/paddingTop/paddingBottom/paddingLeft/paddingRight css style
font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily css style
lineHeight css style
letterSpacing css style
textDecoration css style
textIndent css style
wordWrap css style
wordBreak css style
whiteSpace css style

Setting a selection that has a style applied cancels the style. The css style represents the allowed values specified in css.

# EditorContext.getContents

EditorContext.getContents(Object object)

Gets the editor content

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function

Parameters

Object res

Properties Type Description
html string Tagged HTML content
text string Plain text content
delta Object Represents the content of the delta object

# EditorContext.getSelectionText

EditorContext.getSelectionText(Object object)

Gets the plain text content in the editor's selected area. When the editor is out of focus or an interval is not selected, the return content is empty.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function

Parameters

Object res

Properties Type Description
text string Plain text content

# EditorContext.insertDivider

EditorContext.insertDivider(Object object)

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.insertImage

EditorContext.insertImage(Object object)

Insert a picture.

When the address is a temporary file, the data-local attribute is added to the \ tag in the editor html format content, and the data-local field is added to the image attributes attribute property in the delta format content, and the value is the address of the temporary file that is passed in.

Developers can choose to upload images to the server during the submission stage, obtain the network address and replace it. Replace the src value of \ for html content and insert { image: abc } for delta content.

Parameters

Object object

Properties Type The default value is Required Description
src string Yes Image address, only http(s), base64, cloud image (2.8.0), temporary file (2.8.3)
alt string No Alternate text
width string No Image width (pixels/percentage)
height string No Image height (pixels/percentage)
extClass string No Add the class name
data Object No data is serialized as name=value; The format of name1=value2 hangs on the property data-custom
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

# EditorContext.insertText

EditorContext.insertText(Object object)

Overwrites the current selection and sets a piece of text

Parameters

Object object

Properties Type The default value is Required Description
text string No Text content
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.redo

EditorContext.redo(Object object)

recover

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.removeFormat

EditorContext.removeFormat(Object object)

Clears the style of the current selection

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.scrollIntoView

EditorContext.scrollIntoView()

Causes the editor cursor to scroll into the visible area of the window.

# EditorContext.setContents

EditorContext.setContents(Object object)

Initialize the editor content, and only delta takes effect when html and delta exist at the same time

Parameters

Object object

Properties Type The default value is Required Description
html string No Tagged HTML content
delta Object No Represents the content of the delta object
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

# EditorContext.undo

EditorContext.undo(Object object)

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)
Last update: 2022/08/16, 21:24:25
Data caching
Map

← Data caching Map→

Copyright © 2020-2024 Neuxnet
  • Follow System
  • Light Mode
  • Dark Mode
  • Reading Mode