Skip to content

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

attributetypeDefault valuesRequiredIntroductions
filePathstringyesImage file path, which can be temporary file path or permanent file path (Local path) Network path not supported
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface 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)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.saveImageToPhotosAlbum({
  filePath: 'finfile://xxxx',
  success(res) { }
})

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
  2. The host app disables the applet from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
  • Interface authorization failure (Android).
  1. 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
  2. the host app prohibits the applet 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

attributetypeDefault valuesRequiredIntroductions
sourcesArray.<Object>yesList of resources to preview
currentnumber0noResource Number Currently Displayed
showmenubooleantruenoDisplays long press menu
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.sources Structure

attributetypeDefault valuesRequiredIntroductions
urlStringyesAddress of a picture or video
typeStringimagenoType of resource, default to picture
posterstringnoCover image of the video

type Legal value

valueIntroductionsMinimum version
imagepicture
videovideo

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

attributetypeDefault valuesRequiredIntroductions
urlsArray.<string>yesA list of links to images that need to be previewed. 2.2.3 Support for cloud file ID
currentstringThe first photo of urlsnoLink to currently displayed picture
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.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

attributetypeDefault valuesRequiredIntroductions
srcstringyesImage path, support network path, local path, code package path
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
widthnumberPicture original width in px. Spin is not considered
heightnumberPicture original height in px. Spin is not considered
pathstringLocal path of picture

sample code

javascript
pz.getImageInfo({
  src: 'images/a.jpg',
  success(res) {
    console.log(res.width)
    console.log(res.height)
  }
})

pz.chooseImage({
  success(res) {
    pz.getImageInfo({
      src: res.tempFilePaths[0],
      success(res) {
        console.log(res.width)
        console.log(res.height)
      }
    })
  }
})

compressImage

pz.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

attributetypeDefault valuesRequiredIntroductions
srcstringyesPicture path, the path of the picture, support local path, code package path
qualitynumber80noCompression mass, range 0100, the smaller the value, the lower the mass, and the higher the compression rate (valid only for jpg)
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)
object.success callback
parameter
attributetypeIntroductions
tempFilePathstringTemporary file path of compressed image (Local path)

sample code

javascript
pz.compressImage({
  src: '', // Picture path
  quality: 80 // Compression mass
})

chooseFile

Select files from client session

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
countnumbertrueyesThe maximum number of files you can choose, you can 0100
typestring'all'noType of file selected
extensionArray.<string>noFilter by filename extension, only type==file Is effective when... Each item cannot be an empty string. No filter by default.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions(If the authorization fails, the error message "fail unauthorized" users are not granted permission to read and write external storage)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.type Legal value

valueIntroductions
allSelect from all files
videoVideo files can only be selected
imageSelect only picture file
fileYou can choose files other than pictures and videos

Note

  • Interface authorization failure (Android): 1.
  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
  2. the host app disables the applet 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

attributetypeDefault valuesRequiredIntroductions
countnumbertrueyesThe maximum number of files you can choose, you can 0100
typestring'all'noType of file selected
extensionArray.<string>noFilter by filename extension, only type==file Is effective when... Each item cannot be an empty string. No filter by default.
camerastring'back'noThe default pull up is either the front or rear camera.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions(If the authorization fails, the error message "fail unauthorized" users are not granted permission to read and write external storage)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.type Legal value

valueIntroductions
allSelect from all files
videoVideo files can only be selected
imageSelect only picture file
fileYou can choose files other than pictures and videos

Note

  • Interface authorization failure (Android): 1.
  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
  2. the host app disables the applet 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

attributetypeDefault valuesRequiredIntroductions
countnumber9noMaximum number of pictures you can choose
sizeTypeArray.<string>['original', 'compressed']noThe size of the selected picture
sourceTypeArray.<string>['album', 'camera']noSelect the source of the image
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface 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)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.sizeType Legal value

valueIntroductions
originalOriginal
compressedCompression diagram

object.sourceType Legal value

valueIntroductions
albumSelect from an album
cameraUsing the camera

object.success callback

parameter

Object res

attributetypeIntroductions
tempFilePathsArray.<string>List of local temp file paths for pictures (Local path)
tempFilesArray.<Object>List of local temporary files for pictures

res.tempFiles Structure

attributetypeIntroductions
pathstringLocal temporary file path (Local path)
sizenumberLocal temporary file size, unit B

sample code

javascript
pz.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:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
  2. The host app disables the applet from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
  • Interface authorization failure (Android).
  1. 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
  2. the host app prohibits the applet from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests

fileToBase64

pz.fileToBase64(Object object)

Convert images to base64 data

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
urlstringyesImage paths, paths to images, local paths supported

object.success callback

parameter

attributetypeIntroductions
datastringConverted base64 data

sample code

javascript
pz.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

attributetypeDefault valuesRequiredIntroductions
filePathstringyesVideo file path, can be temporary file path or permanent file path (Local path)
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface 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)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.saveVideoToPhotosAlbum({
  filePath: 'finfile://xxx',
  success (res) {
    console.log(res.errMsg)
  }
})

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
  2. The host app disables the applet from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
  • Interface authorization failure (Android).
  1. 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
  2. the host app prohibits the applet 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 pz.createVideoContext(string id, Object this)

create video context VideoContext Object. Recommended use pz.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

attributetypeDefault valuesRequiredIntroductions
textstringyesBarrage text
colorstringnoBarrage 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

attributetypeDefault valuesRequiredIntroductions
directionnumbernoSet 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

attributetypeDefault valuesRequiredIntroductions
sourceTypeArray.<string>['album', 'camera']noSource of video selection
compressedbooleantruenoWhether to compress the selected video file
maxDurationnumber60noMaximum time to shoot video, per second
camerastring'back'noThe default pull is the front or rear camera. part Android Mobile phone down due to system ROME No support. Can't take effect.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions(If the authorization fails, the error message "fail unauthorized" users are not granted permission to read and write external storage)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.sourceType Legal value

valueIntroductions
albumSelect video from album
cameraUse your camera to shoot video

object.camera Legal value

valueIntroductions
backDefault pull up rear camera
frontDefault pull up front camera

object.success callback

parameter

Object res

attributetypeIntroductions
coverImagePathstringPreview image path for selected videos
durationnumberTime length of selected video
tempFilePathstringTemporary file path for selected video (Local path)
sizenumberAmount of data for selected video
widthnumberReturns the height of the selected video
heightnumberReturns the width of the selected video

sample code

javascript
pz.chooseVideo({
  sourceType: ['album', 'camera'],
  maxDuration: 60,
  camera: 'back',
  success(res) {
    console.log(res.tempFilePath)
  }
})

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted the album permission
  2. The host app disables the applet from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting album permissions.
  • Interface authorization failure (Android).
  1. the user refuses to authorise, an error message will be returned: unauthorized user not granted permission to read external storage
  2. the host app prohibits the applet 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

attributetypeDefault valuesRequiredIntroductions
urlstringyesThe address of the video source, either a temporary video path or a web video path.
autoplaybooleanfalsenoWhether to compress the selected video file
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.previewVideo({
  url: 'http://static.tripbe.com/videofiles/20121214/9533522808.f4v.mp4',
  autoplay: true,
  success(res) {
    console.log(res.tempFilePath)
  }
})

VideoContext

VideoContext Example, you can use the pz.createVideoContext Get.

VideoContext adopt id With one. video Component binding, the corresponding video Component

Method

  • VideoContext.play()
    Play the video

  • VideoContext.pause()
    Pause video

  • VideoContext.stop()
    Stop the video

  • VideoContext.seek(number position)
    Jump to the specified location

  • VideoContext.sendDanmu(Object data)
    Send barrage

  • VideoContext.playbackRate(number rate)
    Set playback 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

  • 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.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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.startRecord({
  success(res) {
    const tempFilePath = res.tempFilePath
    pz.playVoice({
      filePath: tempFilePath,
    })

    setTimeout(() => { pz.stopVoice() }, 5000)
  }
})

setInnerAudioOption

setInnerAudioOption(Object object) Set up InnerAudioContext The playback option of. Set to take effect globally for the current phizclip

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
mixWithOtherbooleantruenoTo mix with other audio, set to true After that, the music in other apps or Phiz will not be terminated.
obeyMuteSwitchbooleantrueno(Only iOS Is the mute switch followed and set to false After that, the sound can be played even in silent mode
speakerOnbooleantruenotrue Stand for playing on speaker, false Represents handset playback, default is true
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Note To ensure the overall Phiz 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.

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

attributetypeDefault valuesRequiredIntroductions
filePathstringyesFile path of the voice file to be played (Local path)
durationnumber60noSpecify the playing time, after the specified playing time will automatically stop playing, unit: seconds
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.startRecord({
  success(res) {
    const tempFilePath = res.tempFilePath
    pz.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 pz.playVoice When the same file is played, it starts at the pause point. If you want to play from scratch, you need to call pz.stopVoice。

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
pz.startRecord({
  success(res) {
    const tempFilePath = res.tempFilePath
    pz.playVoice({
      filePath: tempFilePath
    })

    setTimeout(() => { pz.pauseVoice() }, 5000)
  }
})

createInnerAudioContext

InnerAudioContext pz.createInnerAudioContext()

Create inside audio context InnerAudioContext Object

Return value

InnerAudioContext

createAudioContext

AudioContext pz.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 pz.createAudioContext Get

AudioContext adopt id With one. audio Component binding, the corresponding audio Component

Method

  • AudioContext.setSrc(string src)
    Set the audio address

  • AudioContext.play()
    Play audio.

  • AudioContext.pause()
    Pause audio

  • AudioContext.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  pz.createAudioContext Obtain audio context context
    this.audioCtx = pz.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 pz.createInnerAudioContext Interface gets an instance

attribute

  • string src
    ​ The address of an audio resource for direct playback. 2.2.3 Start supporting cloud file ID

  • number startTime
    ​ Starting position (s), default to 0

  • boolean autoplay
    Whether to start playing automatically, by default false

  • boolean loop
    Whether to loop, by default false

  • number volume
    Volume. range 01。 Default is 1

  • number playbackRate
    Playback speed. range 0.5-2.0 by default 1。(Android Need 6 And above)

Method

  • InnerAudioContext.play()
    play

  • InnerAudioContext.pause()
    Time out. Playback of paused audio starts at the paused point

  • InnerAudioContext.stop()
    Stop. After the stop audio replay will be played from the beginning

  • InnerAudioContext.seek(number position)
    Jump to the specified location

  • InnerAudioContext.destroy()
    Destroy current instance

  • InnerAudioContext.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 state

  • InnerAudioContext.onPlay(function callback)
    Listen for audio playback events

  • InnerAudioContext.offPlay(function callback)
    Unlisten Audio Playback Event

  • InnerAudioContext.onPause(function callback)
    Listening for audio pause events

  • InnerAudioContext.offPause(function callback)
    Unlisten Audio Pause Event

  • InnerAudioContext.onStop(function callback)
    Listen for audio stop events

  • InnerAudioContext.offStop(function callback)
    Cancel listening audio stop event

  • InnerAudioContext.onEnded(function callback)
    Listen to events where audio plays naturally to the end

  • InnerAudioContext.offEnded(function callback)
    Unlisten for audio natural playback to the end of the event

  • InnerAudioContext.onTimeUpdate(function callback)
    Listen to audio playback progress update events

  • InnerAudioContext.offTimeUpdate(function callback)
    Unlisten audio playback progress update event

  • InnerAudioContext.onError(function callback)
    Listen for audio playback error events

  • InnerAudioContext.offError(function callback)
    Unlisten Audio Playback Error Event

  • InnerAudioContext.onWaiting(function callback)
    Listen for audio loading events. Triggered when audio needs to be stopped and loaded due to insufficient data

  • InnerAudioContext.offWaiting(function callback)
    Unlistening for Audio Loading Events

  • InnerAudioContext.onSeeking(function callback)
    Listen to audio jump operation event

  • InnerAudioContext.offSeeking(function callback)
    Cancel listening audio jump operation event

  • InnerAudioContext.onSeeked(function callback)
    Listen for audio events to complete jump operations

  • InnerAudioContext.offSeeked(function callback)
    Unlisten for an event that completes a jump operation with audio

sample code

javascript
// innerAudioContext.js
const innerAudioContext = pz.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.

pz.stopBackgroundAudio(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Sample code

javascript
pz.stopBackgroundAudio()

seekBackgroundAudio

Control the progress of the music playback.

pz.seekBackgroundAudio(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
positionnumber---yesMusic position, unit: second
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Sample code

javascript
pz.seekBackgroundAudio({
  position: 30
})

playBackgroundAudio

Use a background player to play music.

pz.playBackgroundAudio(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
dataUrlstringyesMusic links, currently supported formats are m4a, aac, mp3, wav
titlestringnoMusic titles
coverImgUrlstringnoCover URL
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

pauseBackgroundAudio

Pause the music.

pz.pauseBackgroundAudio(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Sample code

javascript
pz.pauseBackgroundAudio()

onBackgroundAudioStop

Listen to the music stop event

pz.onBackgroundAudioStop(function callback)

parameter

function callback

Callback function for music stop event

onBackgroundAudioPlay

Listen to music playback events

pz.onBackgroundAudioPlay(function callback)

parameter

function callback

Callback function for music playback event

onBackgroundAudioPause

Listen for music pauses

pz.onBackgroundAudioPause(function callback)

parameter

function callback

Callback function for music pause events

getBackgroundAudioPlayerState

Gets background music playback status.

pz.getBackgroundAudioPlayerState(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
durationnumberLength of selected audio (in s), returned only when music is playing
currentPositionnumberSelected audio playback location (in s), only returned when music is playing
statusnumberPlay state
downloadPercentnumberPercentage of audio download progress, only returned when music is playing
dataUrlstringSong data link, returned only when music is playing

status Legal value

valueIntroductions
0Suspended
1Play
2No music playing

Sample code

javascript
pz.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. phizclip 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 pz.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, wav

  • number 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 value

  • string epname
    ​ Album names, sharing features in native audio players, and sharing out card profiles will also use this value

  • string 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 value

  • string 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 map

  • string webUrl
    ​ Page links, sharing features in native audio players, and shared card profiles will also use this value

  • string protocol
    ​ Audio protocol. Default value is 'http ', setting 'hls' Can support playback HLS Protocol live audio

  • number 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 music

  • BackgroundAudioManager.pause()
    Pause the music

  • BackgroundAudioManager.seek(number currentTime)
    Jump to the specified location

  • BackgroundAudioManager.stop()
    Stop the music

  • BackgroundAudioManager.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 events

  • BackgroundAudioManager.onPause(function callback)
    Listen for background audio pause events

  • BackgroundAudioManager.onStop(function callback)
    Listen for background audio stop event

  • BackgroundAudioManager.onEnded(function callback)
    Monitor background audio natural playback end event

  • BackgroundAudioManager.onTimeUpdate(function callback)
    Listen for background audio playback progress update event, only phizclip in the foreground will callback

  • BackgroundAudioManager.onError(function callback)
    Listen for background audio playback error events

  • BackgroundAudioManager.onWaiting(function callback)
    Listen for audio loading events. Triggered when audio needs to be stopped and loaded due to insufficient data

  • BackgroundAudioManager.onSeeking(function callback)
    Listen to background audio start jump operation event

  • BackgroundAudioManager.onSeeked(function callback)
    Listen to background audio to complete jump operation event

  • BackgroundAudioManager.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 = pz.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 preview

  • LivePusherContext.stop(Object object)
    Stop the push stream while stopping the camera preview

  • LivePusherContext.pause(Object object)
    Suspend push-off

  • LivePusherContext.resume(Object object)
    Recovery push-off

  • LivePusherContext.switchCamera(Object object)
    Switch back and forth cameras

  • LivePusherContext.snapshot(Object object)
    snapshot

  • LivePusherContext.toggleTorch(Object object)
    Switch flashlights

  • LivePusherContext.playBGM(Object object)
    Play background music

  • LivePusherContext.stopBGM(Object object)
    Stop background

  • LivePusherContext.pauseBGM(Object object)
    Pause background

  • LivePusherContext.resumeBGM(Object object)
    Restore the background sound

  • LivePusherContext.setBGMVolume(Object object)
    Set the background volume

  • LivePusherContext.setMICVolume(Object object)
    Set microphone volume

  • LivePusherContext.startPreview(Object object)
    Open camera preview

  • LivePusherContext.stopPreview(Object object)
    Turn off camera preview

createLivePlayerContext

createLivePlayerContext()

create live-player context LivePlayerContext Object. Recommended use pz.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)
    play

  • LivePlayerContext.stop(Object object)
    stop

  • LivePlayerContext.mute(Object object)
    Mute

  • LivePlayerContext.pause(Object object)
    Pause

  • LivePlayerContext.resume(Object object)
    restore

  • LivePlayerContext.requestFullScreen(Object object)
    Enter full screen

  • LivePlayerContext.exitFullScreen(Object object)
    Exit Full Screen

  • LivePlayerContext.exitPictureInPicture(Object object)
    Exit window, which can be called on any page

  • LivePlayerContext.snapshot(Object object)
    screenshot

Sound recording

stopRecord

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38, Dependency extension SDK

stopRecord(Object object)

Stop recording

sample code

javascript
pz.startRecord({
  success(res) {
    const tempFilePath = res.tempFilePath
  }
})
setTimeout(function () {
  pz.stopRecord() // End recording
}, 10000)

startRecord

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38, Dependency extension SDK

startRecord(Object object)

Start recording. When the active call pz.stopRecord, or automatically stop recording when the recording exceeds 1 minute. This interface cannot be called when the user leaves the phizclip

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions (When authorisation fails, an error message is returned: fail unauthorized User has not granted camera, record audio permissions)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
tempFilePathstringTemporary path to recording file (Local path)

sample code

javascript
pz.startRecord({
  success(res) {
    const tempFilePath = res.tempFilePath
  }
})
setTimeout(function () {
  pz.stopRecord() // End recording
}, 10000)

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted microphone permission
  2. The host app disables the applet from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting microphone permissions.
  • Interface authorization failure (Android).
  1. the user refuses to authorise, an error message will be returned: unauthorized the user has not granted camera and record audio permissions
  2. the host app prohibits the applet from initiating permission requests, an error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests

getRecorderManager

RecorderManager pz.getRecorderManager()

ObtainGlobally uniqueRecording Manager RecorderManager

Return value

RecorderManager

RecorderManager

Global unique recording manager

Method

  • RecorderManager.start(Object object)
    Start recording

    parameter

    Object object

    attributetypeDefault valuesRequiredIntroductions
    durationnumber60000noLength of recording, unit Ms, maximum 600000(10 Minutes)
    sampleRatenumber8000noSampling rate (not supported by pc)
    numberOfChannelsnumber2noNumber of recording channels
    encodeBitRatenumber48000noCode rate, valid values are shown in the table below
    formatstringaacnoAudio format
    formatstringaacnoAudio format
    frameSizenumbernoSpecify 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.
    audioSourcestringautonoSpecifies the audio input source for the recording, which can be accessed through the pz.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 rateCoding rate
    800016000 ~ 48000
    1102516000 ~ 48000
    1200024000 ~ 64000
    1600024000 ~ 96000
    2205032000 ~ 128000
    2400032000 ~ 128000
    3200048000 ~ 192000
    4410064000 ~ 320000
    4800064000 ~ 320000

    sampleRate

    Legal valueIntroductions
    80008000 sampling rate
    1102511025 sampling rate
    1600016000 sampling rate
    2205022050 sampling rate
    2400024000 sampling rate
    3200032000 sampling rate
    4410044100 sampling rate
    4800048000 sampling rate

    numberOfChannels

    Legal valueIntroductions
    11 Channel
    22 Channel

    format

    Legal valueIntroductions
    mp3mp3 format
    aacaac format
    wavwav format
    PCMpcm format

    audioSource

    Legal valueIntroductions
    autoAutomatically 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
    buildInMicMobile microphone, limited iOS
    headsetMicWired headphone microphone, limited iOS
    micMicrophone (phone microphone when no headset is plugged in, headset microphone when headset is plugged in), Android only
    camcorderwith Mic, for recording audio and video content, limited Android
    voice_communicationwith Mic, for real-time communication, limited Android
    voice_recognitionwith Mic for speech recognition only Android
  • RecorderManager.pause()
    Pause recording

  • RecorderManager.resume()
    Continue recording

  • RecorderManager.stop()
    Stop recording

    parameter

    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 recording

  • RecorderManager.onResume(function callback)
    Wiretaps continue the event

  • RecorderManager.onPause(function callback)
    Listen to Pause Event

  • RecorderManager.onStop(function callback)
    End of Listening Recording Event

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

  • RecorderManager.onInterruptionBegin(function callback)
    The listening recording was interrupted because the system was in use. The following scenarios trigger this event: Phiz voice chat, Phiz video chat. After this event is triggered, the recording is suspended. pause Event is triggered after this event

  • RecorderManager.onInterruptionEnd(function callback)
    Listening recording interrupt end event. Received. interruptionBegin After the event, all recordings in the phizclip will be suspended, and only after this event can they be successfully recorded again

sample code

javascript
const recorderManager = pz.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:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted microphone permission
  2. The host app disables the applet 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

attributetypeIntroductions
widthnumberWidth of image data rectangle
heightnumberHeight of image data rectangle
dataArrayBufferImage 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 = pz.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

attributetypeDefault valuesRequiredIntroductions
zoomnumberyesZoom level, range[1, maxZoom]。zoom Decimals can be taken to one decimal place. maxZoom Available at bindinitdone In the return value
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

attributetypeIntroductions
zoomnumberThe 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

attributetypeDefault valuesRequiredIntroductionsMinimum version
timeoutCallbackfunctionnoOver 30 s or pages onHide When it ends
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.timeoutCallback callback

parameter

attributetypeIntroductions
tempThumbPathstringTemporary path to cover image file (Local path)
tempVideoPathstringTemporary path to a file for a video (Local path)

CameraContext.stopRecord

CameraContext.stopRecord(Object object)

End Video

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
compressedbooleanfalsenoStart video compression with the same compression effectchooseVideo
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

attributetypeIntroductions
tempThumbPathstringTemporary path to cover image file (Local path)
tempVideoPathstringTemporary path to a file for a video (Local path)

CameraContext.takePhoto

CameraContext.takePhoto(Object object)

Taking photos

parameter

Object object

attributetypeDefault valuesRequiredIntroductionsMinimum version
qualitystringnormalnoImage quality, high/normal/low
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

attributetypeIntroductions
tempImagePathstringTemporary 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributevalue
bold
italic
underline
strike
ins
scriptsub / super
headerH1 / H2 / h3 / H4 / h5 / H6
alignleft / center / right / justify
directionrtl
indent-1 / +1
listordered / bullet / check
colorhex color
backgroundColorhex color
margin/marginTop/marginBottom/marginLeft/marginRightcss style
padding/paddingTop/paddingBottom/paddingLeft/paddingRightcss style
font/fontSize/fontStyle/fontVariant/fontWeightcss style
lineHeightcss style
letterSpacingcss style
textDecorationcss style
textIndentcss style
wordWrapcss style
wordBreakcss style
whiteSpacecss 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
htmlstringTagged HTML content
textstringPlain text content
deltaObjectDelta 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
textstringPlain text content

EditorContext.insertDivider

EditorContext.insertDivider(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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 &lt<img>&gt 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 &lt<img>&gt of src Value, for the delta Content should be replaced insert { image: abc } Value

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
srcstringyesImage address, support only http(s), base64, cloud pictures(2.8.0), provisional documents(2.8.3)
altstringnoAlternate text when the image cannot be displayed
widthstringnoImage width (pixels/Percentage)
heightstringnoPicture height (pixels/Percentage)
extClassstringnoAdd to the picture img Class name on tag
dataObjectnodata Is serialized to be name=valuename1=value2 The format of the hanging property data-custom on
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
textstringnoText content
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
htmlstringnoTagged HTML content
deltaObjectnoDelta object representing content
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

EditorContext.undo

EditorContext.undo(Object object)

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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.

pz.createMediaRecorder(Object canvas, Object options)

parameter

Object canvas

WebGL Object, through the SelectorQuery Acquired node Object or through a pz.createOffscreenCanvas Create off-screen WebGL Canvas object

Object options

attributetypeDefault valuesRequiredIntroductions
durationnumber600noSpecify the length of recording s)Automatic stop is reached. Maximum 7200, Min 5
videoBitsPerSecondnumber1000noVideo bit rate (kbps), minimum 600, Max 3000
gopnumber12noVideo key interval
fpsnumber24novideo fps

Return value

MediaRecorder

MediaRecorder

Method

  • MediaRecorder.pause()
    Pause recording

  • MediaRecorder.resume()
    Resume recording

  • MediaRecorder.start()
    Start recording.

  • MediaRecorder.stop()
    Stop recording.