Appearance
Media
picture
saveImageToPhotosAlbum
Base library 2.0.7 support from iOS version 2.10.7, Android version 2.11.43
saveImageToPhotosAlbum(Object object)
Save the image to the system album
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
filePath | string | yes | Image file path, which can be temporary file path or permanent file path (Local path) Network path not supported | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(When authorization fails, an error message is returned: fail unauthorized The user has not granted read external storage, read/write external storage privileges) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.saveImageToPhotosAlbum({
filePath: 'finfile://xxxx',
success(res) { }
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized the user has not granted permission to read external storage, read/write external storage
- the host app prohibits the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
previewMedia
Preview pictures and videos
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
sources | Array.<Object> | yes | List of resources to preview | |
current | number | 0 | no | Resource Number Currently Displayed |
showmenu | boolean | true | no | Displays long press menu |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.sources Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
url | String | yes | Address of a picture or video | |
type | String | image | no | Type of resource, default to picture |
poster | string | no | Cover image of the video |
type Legal value
value | Introductions | Minimum version |
---|---|---|
image | picture | |
video | video |
previewImage
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
previewImage(Object object)
Preview the picture in full screen on the new page. Preview the process of the user can save pictures, send to friends and other operations
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
urls | Array.<string> | yes | A list of links to images that need to be previewed. 2.2.3 Support for cloud file ID | |
current | string | urls 的第一张 | no | Link to currently displayed picture |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.previewImage({
current: '', // Http link for current picture
urls: [] // List of images to preview http links
})
getImageInfo
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
getImageInfo(Object object)
Get picture information. Network pictures need to configure the download domain to take effect
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
src | string | yes | Image path, support network path, local path, code package path | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
width | number | Picture original width in px. Spin is not considered |
height | number | Picture original height in px. Spin is not considered |
path | string | Local path of picture |
sample code
javascript
ft.getImageInfo({
src: 'images/a.jpg',
success(res) {
console.log(res.width)
console.log(res.height)
}
})
ft.chooseImage({
success(res) {
ft.getImageInfo({
src: res.tempFilePaths[0],
success(res) {
console.log(res.width)
console.log(res.height)
}
})
}
})
compressImage
ft.compressImage(Object object)
Base library 2.0.5 support from iOS version 2.10.4, Android version 2.11.39
Compression image interface, optional compression quality
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
src | string | yes | Picture path, the path of the picture, support local path, code package path | |
quality | number | 80 | no | Compression mass, range 0100, the smaller the value, the lower the mass, and the higher the compression rate (valid only for jpg) |
compressedWidth | number | no | The width of the compressed image, measured in px. If left blank, it will be scaled proportionally based on compressedHeight. | |
compressedHeight | number | no | The width of the compressed image, measured in px. If left blank, it will be scaled proportionally based on compressedWidth. | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
attribute | type | Introductions |
---|---|---|
tempFilePath | string | Temporary file path of compressed image (Local path) |
sample code
javascript
ft.compressImage({
src: '', // Picture path
quality: 80 // Compression mass
})
chooseFile
Select files from client session
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
count | number | true | yes | The maximum number of files you can choose, you can 0100 |
type | string | 'all' | no | Type of file selected |
extension | Array.<string> | no | Filter by filename extension, only type==file Is effective when... Each item cannot be an empty string. No filter by default. | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(当授权失败时,返回错误信息:fail unauthorized 用户未授予读写外部存储权限) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.type Legal value
value | Introductions |
---|---|
all | Select from all files |
video | Video files can only be selected |
image | Select only picture file |
file | You can choose files other than pictures and videos |
Note
- Interface authorization failure (Android): 1.
- the user refuses to authorise, an error message is returned: unauthorized The user has not granted permission to read or write to external storage
- the host app disables the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is disabled from initiating permission requests
chooseMessageFile
Supported from base library 1.3.9, needs to be implemented as a custom API
Select a file from the client session
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
count | number | true | yes | The maximum number of files you can choose, you can 0100 |
type | string | 'all' | no | Type of file selected |
extension | Array.<string> | no | Filter by filename extension, only type==file Is effective when... Each item cannot be an empty string. No filter by default. | |
camera | string | 'back' | no | The default pull up is either the front or rear camera. |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(当授权失败时,返回错误信息:fail unauthorized 用户未授予读写外部存储权限) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.type Legal value
value | Introductions |
---|---|
all | Select from all files |
video | Video files can only be selected |
image | Select only picture file |
file | You can choose files other than pictures and videos |
Note
- Interface authorization failure (Android): 1.
- the user refuses to authorise, an error message is returned: unauthorized The user has not granted permission to read or write to external storage
- the host app disables the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is disabled from initiating permission requests
chooseImage
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
chooseImage(Object object)
Select pictures from local albums or use the camera to take photos
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
count | number | 9 | no | Maximum number of pictures you can choose |
sizeType | Array.<string> | ['original', 'compressed'] | no | The size of the selected picture |
sourceType | Array.<string> | ['album', 'camera'] | no | Select the source of the image |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(When authorization fails, an error message is returned: fail unauthorized The user has not been granted read external storage, read/write external storage privileges) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.sizeType Legal value
value | Introductions |
---|---|
original | Original |
compressed | Compression diagram |
object.sourceType Legal value
value | Introductions |
---|---|
album | Select from an album |
camera | Using the camera |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
tempFilePaths | Array.<string> | List of local temp file paths for pictures (Local path) |
tempFiles | Array.<Object> | List of local temporary files for pictures |
res.tempFiles Structure
attribute | type | Introductions |
---|---|---|
path | string | Local temporary file path (Local path) |
size | number | Local temporary file size, unit B |
sample code
javascript
ft.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// TempFilePath can display pictures as src attribute of img tag
const tempFilePaths = res.tempFilePaths
}
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized the user has not granted permission to read external storage, read/write external storage
- the host app prohibits the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
fileToBase64
ft.fileToBase64(Object object)
Convert images to base64 data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
url | string | yes | Image paths, paths to images, local paths supported |
object.success callback
parameter
attribute | type | Introductions |
---|---|---|
data | string | Converted base64 data |
sample code
javascript
ft.fileToBase64({
url: '', // Image path
})
video
saveVideoToPhotosAlbum
Base library 2.0.7 support from iOS version 2.10.7, Android version 2.11.43
saveVideoToPhotosAlbum(Object object)
Save the video to the system album. Support mp4 video format
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
filePath | string | yes | Video file path, can be temporary file path or permanent file path (Local path) | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(When authorization fails, an error message is returned: fail unauthorized The user has not granted read external storage, read/write external storage privileges) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.saveVideoToPhotosAlbum({
filePath: 'finfile://xxx',
success (res) {
console.log(res.errMsg)
}
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized the user has not granted permission to read external storage, read/write external storage
- the host app prohibits the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
createVideoContext
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1 VideoContext ft.createVideoContext(string id, Object this)
create video context VideoContext Object. Recommended use ft.createSelectorQuery Obtain context Object
parameter
string id
video Component id
Object this
Under a custom component, the this of the current component instance to manipulate within the component video assembly
Return value
VideoContext
VideoContext Method
VideoContext.play()
Play the video
VideoContext.pause()
Pause video
VideoContext.stop()
Stop the video
VideoContext.seek(number position)
Jump to the specified location
position Unit s
VideoContext.sendDanmu(Object data)
Send barrage
parameter
Object data
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
text | string | yes | Barrage text | |
color | string | no | Barrage Color |
VideoContext.playbackRate(number rate)
Set playback speed
Multiplier, support 0.5/0.8/1.0/1.25/1.5,2.6.3 Rise support 2.0 Double speed
VideoContext.requestFullScreen(Object object)
Go to full screen. If you have custom content that needs to be displayed at full screen, place the content node in the video Node
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
direction | number | no | Set the direction of the video at full screen. If not specified, it will be judged automatically according to the aspect ratio. |
VideoContext.exitFullScreen()
Exit Full Screen
VideoContext.showStatusBar()
Display status bar, valid for iOS full screen only
VideoContext.hideStatusBar()
Hide the status bar, only available in full iOS screen
VideoContext.requestBackgroundPlayback()
Enter background audio playback mode
VideoContext.exitBackgroundPlayback()
Exit background audio playback mode.
chooseVideo
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
chooseVideo(Object object)
Shoot a video or select a video from your phone album
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
sourceType | Array.<string> | ['album', 'camera'] | no | Source of video selection |
compressed | boolean | true | no | Whether to compress the selected video file |
maxDuration | number | 60 | no | Maximum time to shoot video, per second |
camera | string | 'back' | no | The default pull is the front or rear camera. part Android Mobile phone down due to system ROME No support. Can't take effect. |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(当授权失败时,返回错误信息:fail unauthorized 用户未授予读取外部存储权限) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.sourceType Legal value
value | Introductions |
---|---|
album | Select video from album |
camera | Use your camera to shoot video |
object.camera Legal value
value | Introductions |
---|---|
back | Default pull up rear camera |
front | Default pull up front camera |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
coverImagePath | string | Preview image path for selected videos |
duration | number | Time length of selected video |
tempFilePath | string | Temporary file path for selected video (Local path) |
size | number | Amount of data for selected video |
width | number | Returns the height of the selected video |
height | number | Returns the width of the selected video |
sample code
javascript
ft.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success(res) {
console.log(res.tempFilePath)
}
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized user not granted permission to read external storage
- the host app prohibits the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
previewVideo
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
previewVideo(Object object)
Full screen preview of the video in a new page.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
url | string | yes | The address of the video source, either a temporary video path or a web video path. | |
autoplay | boolean | false | no | Whether to compress the selected video file |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.previewVideo({
url: 'http://static.tripbe.com/videofiles/20121214/9533522808.f4v.mp4',
autoplay: true,
success(res) {
console.log(res.tempFilePath)
}
})
getVideoInfo
Base library support from 3.1.17, iOS version 2.42.11, Android version 2.42.11
getVideoInfo(Object object)
Get detailed information about a video.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
src | string | yes | Video file path, local file path starting with a custom protocol | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success
parameter
Object res
attribute | type | Introductions |
---|---|---|
orientation | string | Screen orientation of the video |
type | string | Video format |
duration | number | Video duration |
size | number | Video size, in kB |
height | number | Video height, in pixels |
width | number | Video width, in pixels |
fps | number | Video frame rate |
bitrate | number | Video bitrate, in kbps |
res.orientation
Value | Introductions |
---|---|
up | Default |
down | 180-degree rotation |
left | Counterclockwise 90-degree rotation |
right | Clockwise 90-degree rotation |
up-mirrored | Same as up, but horizontally flipped |
down-mirrored | Same as down, but horizontally flipped |
left-mirrored | Same as left, but vertically flipped |
right-mirrored | Same as right, but vertically flipped |
sample code
javascript
ft.getVideoInfo({
path: wx.env.USER_DATA_PATH + '/path/to/video.mp4'
success(res) {
console.log(res)
}
})
VideoContext
VideoContext Example, you can use the ft.createVideoContext Get.
VideoContext adopt id With one. video Component binding, the corresponding video Component
Method
VideoContext.play()
Play the videoVideoContext.pause()
Pause videoVideoContext.stop()
Stop the videoVideoContext.seek(number position)
Jump to the specified locationVideoContext.sendDanmu(Object data)
Send barrageVideoContext.playbackRate(number rate)
Set playback speedVideoContext.requestFullScreen(Object object)
Go to full screen. If you have custom content that needs to be displayed at full screen, place the content node in the video NodeVideoContext.exitFullScreen()
Exit Full ScreenVideoContext.showStatusBar()
Display status bar, valid for iOS full screen onlyVideoContext.hideStatusBar()
Hide the status bar, only available in full iOS screenVideoContext.exitPictureInPicture()
Exit window, which can be called on any page
audio frequency
stopVoice
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
stopVoice(Object object)
End playback
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.startRecord({
success(res) {
const tempFilePath = res.tempFilePath
ft.playVoice({
filePath: tempFilePath,
})
setTimeout(() => { ft.stopVoice() }, 5000)
}
})
setInnerAudioOption
setInnerAudioOption(Object object) Set up InnerAudioContext
The playback option of. Set to take effect globally for the current Mini Program
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
mixWithOther | boolean | true | no | To mix with other audio, set to true After that, the music in other apps or WeChat will not be terminated. |
obeyMuteSwitch | boolean | true | no | (Only iOS Is the mute switch followed and set to false After that, the sound can be played even in silent mode |
speakerOn | boolean | true | no | true Stand for playing on speaker, false Represents handset playback, default is true |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) | |
Note | ||||
To ensure the overall WeChat experience, speaker on for true The client ignores the mixWithOthers Parameter to enforce mutex with other audio | ||||
It is not supported to switch to the speaker while playing the audio. If you need to switch, you can first pause the audio and record the time point of the current pause, and then switch to play the audio again from the original time point. | ||||
at present ft.setInnerAudioOption Interface incompatibility ft.createWebAudioContext Interface, not compatible ft.createInnerAudioContext open useWebAudioImplement Will be supported in subsequent versions | success | function |
playVoice
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
playVoice(Object object)
Start playing the voice. At the same time only allows a voice file is playing, if the previous voice file has not played over, will interrupt a previous voice playback
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
filePath | string | yes | File path of the voice file to be played (Local path) | |
duration | number | 60 | no | Specify the playing time, after the specified playing time will automatically stop playing, unit: seconds |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.startRecord({
success(res) {
const tempFilePath = res.tempFilePath
ft.playVoice({
filePath: tempFilePath,
complete() { }
})
}
})
pauseVoice
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
pauseVoice(Object object)
Pauses a voice that is playing. Call again ft.playVoice When the same file is played, it starts at the pause point. If you want to play from scratch, you need to call ft.stopVoice。
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.startRecord({
success(res) {
const tempFilePath = res.tempFilePath
ft.playVoice({
filePath: tempFilePath
})
setTimeout(() => { ft.pauseVoice() }, 5000)
}
})
getAvailableAudioSources
Base library support from 3.1.17, iOS version 2.42.11, Android version 2.42.11
getAvailableAudioSources(Object object)
Obtain currently supported audio input sources
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
audioSources | Array.<string> | List of supported audio input sources |
res.audioSources
Value | Description |
---|---|
auto | Automatically set, default to using the phone's microphone; switches to the headset microphone when earphones are plugged in. Applicable to all platforms. |
buildInMic | Phone's microphone only, limited to iOS. |
headsetMic | Headset microphone only, limited to iOS. |
mic | Microphone (phone's microphone when no earphones are plugged in, and headset microphone when earphones are plugged in), limited to Android. |
camcorder | Same as mic, suitable for recording audio and video content, limited to Android. |
voice_communication | Same as mic, suitable for real-time communication, limited to Android. |
voice_recognition | Same as mic, suitable for voice recognition, limited to Android. |
sample code
javascript
ft.getAvailableAudioSources({
success(res) {
console.log(res.audioSources)
}
})
createInnerAudioContext
InnerAudioContext ft.createInnerAudioContext()
Create inside audio context InnerAudioContext Object
Return value
InnerAudioContext
createAudioContext
AudioContext ft.createAudioContext(string id, Object this)
create audio context AudioContext Object.
parameter
string id
audio Component id
Object this
Under a custom component, the this of the current component instance to manipulate within the component audio assembly
Return value
AudioContext
AudioContext
AudioContext Example, you can use the ft.createAudioContext Get
AudioContext adopt id With one. audio Component binding, the corresponding audio Component
Method
AudioContext.setSrc(string src)
Set the audio addressAudioContext.play()
Play audio.AudioContext.pause()
Pause audioAudioContext.seek(number position)
Jump to the specified location.
sample code
html
<!-- audio.FXML -->
<audio src="{{src}}" id="myAudio" ></audio>
<button type="primary" Bindtap = "audioPlay">play</button>
<button type="primary" Bindtap = "audiopause">Pause</button>
<button type="primary" bindtap="audio14">Set the current playback time to 14 seconds</button>
<button type="primary" Bindtap = "audioStart">Back to the beginning.</button>
javascript
// audio.js
Page({
onReady (e) {
// Use ft.createAudioContext Obtain audio context context
this.audioCtx = ft.createAudioContext('myAudio')
this.audioCtx.setSrc('http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46')
this.audioCtx.play()
},
data: {
src: ''
},
audioPlay () {
this.audioCtx.play()
},
audioPause () {
this.audioCtx.pause()
},
audio14 () {
this.audioCtx.seek(14)
},
audioStart () {
this.audioCtx.seek(0)
}
})
InnerAudioContext
InnerAudioContext Example, you can use the ft.createInnerAudioContext Interface gets an instance
attribute
string src
The address of an audio resource for direct playback. 2.2.3 Start supporting cloud file IDnumber startTime
Starting position (s), default to 0boolean autoplay
Whether to start playing automatically, by default falseboolean loop
Whether to loop, by default falsenumber volume
Volume. range 01。 Default is 1number playbackRate
Playback speed. range 0.5-2.0 by default 1。(Android Need 6 And above)
Method
InnerAudioContext.play()
playInnerAudioContext.pause()
Time out. Playback of paused audio starts at the paused pointInnerAudioContext.stop()
Stop. After the stop audio replay will be played from the beginningInnerAudioContext.seek(number position)
Jump to the specified locationInnerAudioContext.destroy()
Destroy current instanceInnerAudioContext.onCanplay(function callback)
Listen for events in which audio enters playable state. But it doesn't guarantee a smooth playback
InnerAudioContext.offCanplay(function callback)
Event that cancels listening for audio entering playable stateInnerAudioContext.onPlay(function callback)
Listen for audio playback eventsInnerAudioContext.offPlay(function callback)
Unlisten Audio Playback EventInnerAudioContext.onPause(function callback)
Listening for audio pause eventsInnerAudioContext.offPause(function callback)
Unlisten Audio Pause EventInnerAudioContext.onStop(function callback)
Listen for audio stop eventsInnerAudioContext.offStop(function callback)
Cancel listening audio stop eventInnerAudioContext.onEnded(function callback)
Listen to events where audio plays naturally to the endInnerAudioContext.offEnded(function callback)
Unlisten for audio natural playback to the end of the eventInnerAudioContext.onTimeUpdate(function callback)
Listen to audio playback progress update eventsInnerAudioContext.offTimeUpdate(function callback)
Unlisten audio playback progress update eventInnerAudioContext.onError(function callback)
Listen for audio playback error eventsInnerAudioContext.offError(function callback)
Unlisten Audio Playback Error EventInnerAudioContext.onWaiting(function callback)
Listen for audio loading events. Triggered when audio needs to be stopped and loaded due to insufficient dataInnerAudioContext.offWaiting(function callback)
Unlistening for Audio Loading EventsInnerAudioContext.onSeeking(function callback)
Listen to audio jump operation eventInnerAudioContext.offSeeking(function callback)
Cancel listening audio jump operation eventInnerAudioContext.onSeeked(function callback)
Listen for audio events to complete jump operationsInnerAudioContext.offSeeked(function callback)
Unlisten for an event that completes a jump operation with audio
sample code
javascript
// innerAudioContext.js
const innerAudioContext = ft.createInnerAudioContext()
innerAudioContext.autoplay = true
innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
innerAudioContext.onPlay(() => {
console.log('Start playing.')
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
Background audio
stopBackgroundAudio
Stop playing the music.
wx.stopBackgroundAudio(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Sample code
javascript
wx.stopBackgroundAudio()
seekBackgroundAudio
Control the progress of the music playback.
wx.seekBackgroundAudio(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
position | number | --- | 是 | 音乐位置,单位:秒 |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Sample code
javascript
wx.seekBackgroundAudio({
position: 30
})
playBackgroundAudio
Use a background player to play music.
wx.playBackgroundAudio(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
dataUrl | string | yes | Music links, currently supported formats are m4a, aac, mp3, wav | |
title | string | no | Music titles | |
coverImgUrl | string | no | Cover URL | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
pauseBackgroundAudio
Pause the music.
wx.pauseBackgroundAudio(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Sample code
javascript
wx.pauseBackgroundAudio()
onBackgroundAudioStop
Listen to the music stop event
wx.onBackgroundAudioStop(function callback)
parameter
function callback
Callback function for music stop event
onBackgroundAudioPlay
Listen to music playback events
wx.onBackgroundAudioPlay(function callback)
parameter
function callback
Callback function for music playback event
onBackgroundAudioPause
Listen for music pauses
wx.onBackgroundAudioPause(function callback)
parameter
function callback
Callback function for music pause events
getBackgroundAudioPlayerState
Gets background music playback status.
wx.getBackgroundAudioPlayerState(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
duration | number | Length of selected audio (in s), returned only when music is playing |
currentPosition | number | Selected audio playback location (in s), only returned when music is playing |
status | number | Play state |
downloadPercent | number | Percentage of audio download progress, only returned when music is playing |
dataUrl | string | Song data link, returned only when music is playing |
status Legal value
value | Introductions |
---|---|
0 | Suspended |
1 | Play |
2 | No music playing |
Sample code
javascript
wx.getBackgroundAudioPlayerState({
success (res) {
const status = res.status
const dataUrl = res.dataUrl
const currentPosition = res.currentPosition
const duration = res.duration
const downloadPercent = res.downloadPercent
}
})
getBackgroundAudioManager
ObtainGlobally uniqueBackground Audio Manager. Mini Program cut into the background, if the audio is playing state, you can continue to play. But the background state cannot manipulate the playback state of the audio by calling the API.
Return value
BackgroundAudioManager
BackgroundAudioManager
BackgroundAudioManager Example, you can use the ft.getBackgroundAudioManager Get
Notes. The ability to play audio in the background of iOS BackgroundAudioManager requires the user to add it to target-capabilities, background Modes and check audio,AirPlay,and Picture in Picture
attribute
string src
Audio data source (2.2.3 Start supporting cloud file ID). Default is empty string,When a new src Will automatically start playingCurrently supported formats are m4a, aac, mp3, wavnumber startTime
Where the audio starts playing (in s).string title
Audio title for native audio player audio title (required). The share function in the native audio player, which shares out the card title, will also use this valuestring epname
Album names, sharing features in native audio players, and sharing out card profiles will also use this valuestring singer
The name of the singer, the sharing function in the native audio player, and the sharing of the card profile will also use this valuestring coverImgUrl
Cover picture URL, used to do native audio player background map. Native audio player in the sharing function, share out of the card layout and background will also use the mapstring webUrl
Page links, sharing features in native audio players, and shared card profiles will also use this valuestring protocol
Audio protocol. Default value is 'http ', setting 'hls' Can support playback HLS Protocol live audionumber playbackRate
Playback speed. range 0.5-2.0 by default 1。(Android Need 6 And above)number duration
Length of current audio (in s), only if there is a valid src Returns when. (Read Only)number currentTime
Current audio playback position (unit: s), only if there is a legitimate src Returns when. (Read Only)boolean paused
Whether the current pause or stop. (Read Only)number buffered
The time that the audio has been buffered, ensuring only that the content at this point in time is buffered. (Read Only)string referrerPolicy
Not supported
Method
BackgroundAudioManager.play()
Play musicBackgroundAudioManager.pause()
Pause the musicBackgroundAudioManager.seek(number currentTime)
Jump to the specified locationBackgroundAudioManager.stop()
Stop the musicBackgroundAudioManager.onCanplay(function callback)
Listen for background audio to enter a playable state event. But it doesn't guarantee a smooth playback
BackgroundAudioManager.onPlay(function callback)
Listen for background audio playback eventsBackgroundAudioManager.onPause(function callback)
Listen for background audio pause eventsBackgroundAudioManager.onStop(function callback)
Listen for background audio stop eventBackgroundAudioManager.onEnded(function callback)
Monitor background audio natural playback end eventBackgroundAudioManager.onTimeUpdate(function callback)
Listen for background audio playback progress update event, only Mini Program in the foreground will callbackBackgroundAudioManager.onError(function callback)
Listen for background audio playback error eventsBackgroundAudioManager.onWaiting(function callback)
Listen for audio loading events. Triggered when audio needs to be stopped and loaded due to insufficient dataBackgroundAudioManager.onSeeking(function callback)
Listen to background audio start jump operation eventBackgroundAudioManager.onSeeked(function callback)
Listen to background audio to complete jump operation eventBackgroundAudioManager.onNext(function callback)
Listen to the user click on the next song event in the system music play panel (iOS only)BackgroundAudioManager.onPrev(function callback)
Listen to the user click on the previous event in the system music player panel (iOS only)
sample code
javascript
const backgroundAudioManager = ft.getBackgroundAudioManager()
backgroundAudioManager.title = 'Here and now.'
backgroundAudioManager.epname = 'Here and now.'
backgroundAudioManager.singer = 'Xu wei'
backgroundAudioManager.coverImgUrl = 'http://xxx'
// Set src And it will play automatically.
backgroundAudioManager.src = 'http://xxx'
Real-time audio and video
createLivePusherContext
createLivePusherContext()
create live-pusher context LivePusherContext Object.
Return value
LivePusherContext
Method
LivePusherContext.start(Object object)
Start pushing the flow while turning on camera previewLivePusherContext.stop(Object object)
Stop the push stream while stopping the camera previewLivePusherContext.pause(Object object)
Suspend push-offLivePusherContext.resume(Object object)
Recovery push-offLivePusherContext.switchCamera(Object object)
Switch back and forth camerasLivePusherContext.snapshot(Object object)
snapshotLivePusherContext.toggleTorch(Object object)
Switch flashlightsLivePusherContext.playBGM(Object object)
Play background musicLivePusherContext.stopBGM(Object object)
Stop backgroundLivePusherContext.pauseBGM(Object object)
Pause backgroundLivePusherContext.resumeBGM(Object object)
Restore the background soundLivePusherContext.setBGMVolume(Object object)
Set the background volumeLivePusherContext.setMICVolume(Object object)
Set microphone volumeLivePusherContext.startPreview(Object object)
Open camera previewLivePusherContext.stopPreview(Object object)
Turn off camera preview
createLivePlayerContext
createLivePlayerContext()
create live-player context LivePlayerContext Object. Recommended use ft.createSelectorQuery Obtain context Object
parameter
string id
live-player Component id
Object this
Under a custom component, the this of the current component instance to manipulate within the component live-player assembly
Return value
LivePlayerContext
Method
LivePlayerContext.play(Object object)
playLivePlayerContext.stop(Object object)
stopLivePlayerContext.mute(Object object)
MuteLivePlayerContext.pause(Object object)
PauseLivePlayerContext.resume(Object object)
restoreLivePlayerContext.requestFullScreen(Object object)
Enter full screenLivePlayerContext.exitFullScreen(Object object)
Exit Full ScreenLivePlayerContext.exitPictureInPicture(Object object)
Exit window, which can be called on any pageLivePlayerContext.snapshot(Object object)
screenshot
Sound recording
stopRecord
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38, 依赖扩展 SDK
stopRecord(Object object)
Stop recording
sample code
javascript
ft.startRecord({
success(res) {
const tempFilePath = res.tempFilePath
}
})
setTimeout(function () {
ft.stopRecord() // End recording
}, 10000)
startRecord
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38, 依赖扩展 SDK
startRecord(Object object)
Start recording. When the active call ft.stopRecord, or automatically stop recording when the recording exceeds 1 minute. This interface cannot be called when the user leaves the Mini Program
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions (When authorisation fails, an error message is returned: fail unauthorized User has not granted camera, record audio permissions) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
tempFilePath | string | Temporary path to recording file (Local path) |
sample code
javascript
ft.startRecord({
success(res) {
const tempFilePath = res.tempFilePath
}
})
setTimeout(function () {
ft.stopRecord() // End recording
}, 10000)
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted microphone permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting microphone permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized the user has not granted camera and record audio permissions
- the host app prohibits the mini progmini programrams from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
getRecorderManager
RecorderManager ft.getRecorderManager()
ObtainGlobally uniqueRecording Manager RecorderManager
Return value
RecorderManager
RecorderManager
Global unique recording manager
Method
RecorderManager.start(Object object)
Start recordingparameter
Object object
attribute type Default values Required Introductions duration number 60000 no Length of recording, unit Ms, maximum 600000(10 Minutes) sampleRate number 8000 no Sampling rate (not supported by pc) numberOfChannels number 2 no Number of recording channels encodeBitRate number 48000 no Code rate, valid values are shown in the table below format string aac no Audio format format string aac no Audio format frameSize number no Specify frame size, in units KB。 to import frameSize Each time a specified frame size is recorded, the recorded file content will be called back, not specified, no callback. Support only temporarily mp3、pcm Format. audioSource string auto no Specifies the audio input source for the recording, which can be accessed through the ft.getAvailableAudioSources() Get the currently available audio source Sampling Rate and Code Rate Restriction
Each sampling rate has the corresponding valid value of the coding rate range, setting illegal sampling rate or coding rate will lead to recording failure, the specific corresponding relationship as follows
sampling rate Coding rate 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
Legal value Introductions 8000 8000 sampling rate 11025 11025 sampling rate 16000 16000 sampling rate 22050 22050 sampling rate 24000 24000 sampling rate 32000 32000 sampling rate 44100 44100 sampling rate 48000 48000 sampling rate numberOfChannels
Legal value Introductions 1 1 Channel 2 2 Channel format
Legal value Introductions mp3 mp3 format aac aac format wav wav format PCM pcm format audioSource
Legal value Introductions auto Automatically set to use the phone microphone by default and switch to the headset microphone automatically when the headset is plugged in, available on all platforms buildInMic Mobile microphone, limited iOS headsetMic Wired headphone microphone, limited iOS mic Microphone (phone microphone when no headset is plugged in, headset microphone when headset is plugged in), Android only camcorder with Mic, for recording audio and video content, limited Android voice_communication with Mic, for real-time communication, limited Android voice_recognition with Mic for speech recognition only Android RecorderManager.pause()
Pause recordingRecorderManager.resume()
Continue recordingRecorderManager.stop()
Stop recordingparameter
Object object
| attribute | type | Introductions | | --- | --- | --- | --- | --- | | tempFilePath | string | Temporary path to recording file (Local path) | | duration | number | Total duration of recording in ms | | fileSize | number | Recording file size in Byte |
RecorderManager.onStart(function callback)
Start of listening recordingRecorderManager.onResume(function callback)
Wiretaps continue the eventRecorderManager.onPause(function callback)
Listen to Pause EventRecorderManager.onStop(function callback)
End of Listening Recording Event
RecorderManager.onError(function callback)
Listen for recording error eventsRecorderManager.onInterruptionBegin(function callback)
The listening recording was interrupted because the system was in use. The following scenarios trigger this event: WeChat voice chat, WeChat video chat. After this event is triggered, the recording is suspended. pause Event is triggered after this eventRecorderManager.onInterruptionEnd(function callback)
Listening recording interrupt end event. Received. interruptionBegin After the event, all recordings in the Mini Program will be suspended, and only after this event can they be successfully recorded again
sample code
javascript
const recorderManager = ft.getRecorderManager()
recorderManager.onStart(() => {
console.log('recorder start')
})
recorderManager.onPause(() => {
console.log('recorder pause')
})
recorderManager.onStop((res) => {
console.log('recorder stop', res)
const { tempFilePath } = res
})
recorderManager.onFrameRecorded((res) => {
const { frameBuffer } = res
console.log('frameBuffer.byteLength', frameBuffer.byteLength)
})
const options = {
duration: 10000,
sampleRate: 44100,
numberOfChannels: 1,
encodeBitRate: 192000,
format: 'aac',
frameSize: 50
}
recorderManager.start(options)
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted microphone permission
- The host app disables the mini progmini programrams from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting microphone permissions
camera
createCameraContext
createCameraContext()
create camera context CameraContext Object
Return value
CameraContext
CameraContext.onCameraFrame
CameraFrameListener CameraContext.onCameraFrame(function callback)
Obtain Camera Real-time frame data
parameter
function callback
callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
width | number | Width of image data rectangle |
height | number | Height of image data rectangle |
data | ArrayBuffer | Image pixel data, one-dimensional array, every four items representing a pixel rgba |
Return value
CameraFrameListener
Note: To use this interface you must also specify frame-size in the camera component attribute.
sample code
javascript
const context = ft.createCameraContext()
const listener = context.onCameraFrame((frame) => {
console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height)
})
listener.start()
CameraContext.setZoom
CameraContext.setZoom(Object object)
Set Zoom Level
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
zoom | number | yes | 缩Zoom level, range[1, maxZoom]。zoom Decimals can be taken to one decimal place. maxZoom Available at bindinitdone In the return value | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
attribute | type | Introductions |
---|---|---|
zoom | number | The scale level that is actually set. Due to system limitations, some models may not be able to set to the specified value, will be replaced by the nearest settable value. |
CameraContext.startRecord
CameraContext.startRecord(Object object)
Start recording
parameter
Object object
attribute | type | Default values | Required | Introductions | Minimum version |
---|---|---|---|---|---|
timeoutCallback | function | no | Over 30 s or pages onHide When it ends | ||
success | function | no | Interface calls the successful callback function | ||
fail | function | no | Interface calls failed callback functions | ||
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.timeoutCallback callback
parameter
attribute | type | Introductions |
---|---|---|
tempThumbPath | string | Temporary path to cover image file (Local path) |
tempVideoPath | string | Temporary path to a file for a video (Local path) |
CameraContext.stopRecord
CameraContext.stopRecord(Object object)
End Video
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
compressed | boolean | false | no | Start video compression with the same compression effectchooseVideo |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
attribute | type | Introductions |
---|---|---|
tempThumbPath | string | Temporary path to cover image file (Local path) |
tempVideoPath | string | Temporary path to a file for a video (Local path) |
CameraContext.takePhoto
CameraContext.takePhoto(Object object)
Taking photos
parameter
Object object
attribute | type | Default values | Required | Introductions | Minimum version |
---|---|---|---|---|---|
quality | string | normal | no | Image quality, high/normal/low | |
success | function | no | Interface calls the successful callback function | ||
fail | function | no | Interface calls failed callback functions | ||
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
attribute | type | Introductions |
---|---|---|
tempImagePath | string | Temporary path to photo file (Local path), Android is jpg image format, ios is png |
CameraFrameListener.start
CameraFrameListener.start(Object object)
Start monitoring the frame data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
CameraFrameListener.stop
CameraFrameListener.stop(Object object)
Stop listening for frame data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Rich text
EditorContext.blur
EditorContext.blur(Object object)
The editor is out of focus and the keyboard is retracted
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.clear
EditorContext.clear(Object object)
Clear editor content
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.format
EditorContext.format(string name, string value)
Modify Style
parameter
string name
attribute
string value
value
Style list supporting settings
attribute | 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 | css style |
lineHeight | css style |
letterSpacing | css style |
textDecoration | css style |
textIndent | css style |
wordWrap | css style |
wordBreak | css style |
whiteSpace | css style |
Selection settings that have already applied styles cancel styles. css style Express css The allowable value specified in
EditorContext.getContents
EditorContext.getContents(Object object)
Get editor content
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
html | string | Tagged HTML content |
text | string | Plain text content |
delta | Object | Delta object representing content |
EditorContext.getSelectionText
EditorContext.getSelectionText(Object object)
Gets the plain text content in the selected area of the editor. Returns empty when the editor is out of focus or an interval is not selected
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
text | string | Plain text content |
EditorContext.insertDivider
EditorContext.insertDivider(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.insertImage
EditorContext.insertImage(Object object)
Insert picture.
When the address is a temporary file, the contents of the editor html format obtained in the <<img>> Tag Add Properties data-local,delta Pictures in Format Content attributes Attribute increase data-local Field, which is the temporary file address that was passed in.
The developer can choose to upload the image to the server during the submission phase, obtain the network address and replace it. Replace the html content with the <<img>> of src Value, for the delta Content should be replaced insert { image: abc } Value
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
src | string | yes | Image address, support only http(s), base64, cloud pictures(2.8.0), provisional documents(2.8.3) | |
alt | string | no | Alternate text when the image cannot be displayed | |
width | string | no | Image width (pixels/Percentage) | |
height | string | no | Picture height (pixels/Percentage) | |
extClass | string | no | Add to the picture img Class name on tag | |
data | Object | no | data Is serialized to be name=valuename1=value2 The format of the hanging property data-custom on | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
this.editorCtx.insertImage({
src: 'xx',
width: '100px',
height: '50px',
extClass: className
})
EditorContext.insertText
EditorContext.insertText(Object object)
Overwrite the current selection, set a text
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
text | string | no | Text content | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.redo
EditorContext.redo(Object object)
restore
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.removeFormat
EditorContext.removeFormat(Object object)
Clear the style of the current selection
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.scrollIntoView
EditorContext.scrollIntoView()
Scrolls the editor cursor to the viewable area of the window
EditorContext.setContents
EditorContext.setContents(Object object)
Initializes editor content, only delta takes effect when html and delta exist together
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
html | string | no | Tagged HTML content | |
delta | Object | no | Delta object representing content | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
EditorContext.undo
EditorContext.undo(Object object)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
createMediaRecorder
create WebGL Picture recorder, which can be recorded frame by frame in WebGL And export the video file.
wx.createMediaRecorder(Object canvas, Object options)
parameter
Object canvas
WebGL Object, through the SelectorQuery Acquired node Object or through a wx.createOffscreenCanvas Create off-screen WebGL Canvas object
Object options
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
duration | number | 600 | no | Specify the length of recording s)Automatic stop is reached. Maximum 7200, Min 5 |
videoBitsPerSecond | number | 1000 | no | Video bit rate (kbps), minimum 600, Max 3000 |
gop | number | 12 | no | Video key interval |
fps | number | 24 | no | video fps |
Return value
MediaRecorder
MediaRecorder
Method
MediaRecorder.pause()
Pause recordingMediaRecorder.resume()
Resume recordingMediaRecorder.start()
Start recording.MediaRecorder.stop()
Stop recording.