tencent cloud

Feedback

Last updated: 2024-03-07 11:12:14

    saveVideoToPhotosAlbum

    This API is used via wx.saveVideoToPhotosAlbum(Object object).
    Feature Description: Saves videos to the system album.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    filePath
    string
    -
    Yes
    The path of the video file, which can either be a temporary file path or a permanent file path.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.saveVideoToPhotosAlbum({
    filePath: 'qqfile://xxx',
    success(res) {
    console.log(res.errMsg)
    },
    })

    createVideoContext

    This API is used via VideoContext wx.createVideoContext(string id, Object this).
    Feature Description: Creates a VideoContext object.
    Parameter and Description:
    string id: The id of the <video> component.
    "this" of the current component instance under custom components, used to operate the <video> component within.
    Return Value: VideoContext

    chooseVideo

    This API is used via wx.chooseVideo(Object object).
    Feature Description: Captures a video or selects a video from the phone's album.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    sourceType
    Array.\\
    ['album', 'camera']
    No
    Video Selection Source
    compressed
    boolean
    ture
    No
    Whether to compress the selected video file
    maxDuration
    number
    60
    No
    Maximum recording time of video, in seconds.
    camera
    string
    ‘back’
    No
    The default is to activate the front or rear camera. However, on some Android phones, this may not work because the system ROM does not support this feature.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Valid values of object.sourceType
    Value
    Description
    album
    Select video from the album
    camera
    Capture video using the camera
    Valid values of object.camera
    Value
    Description
    back
    Default to activating the rear camera.
    front
    Default to activating the front camera.
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    tempFilePath
    string
    Temporary file path of the selected video.
    duration
    number
    Duration of the selected video.
    size
    number
    Data size of the selected video.
    height
    number
    Return to selecting the height of the selected video.
    width
    number
    Return to selecting the width of the selected video.
    thumbTempFilePath
    string
    Temporary file path of video thumbnail
    Sample Code
    wx.chooseVideo({
    sourceType: ['album', 'camera'],
    maxDuration: 60,
    camera: 'back',
    success(res) {
    console.log(res.tempFilePath)
    },
    })

    compressVideo

    This API is used via wx.compressVideo(Object object).
    Feature Description: Video compression interface. Developers can specify the compression quality through 'quality'. For more precise control, 'bitrate', 'fps', and 'resolution' can be specified. However, when 'quality' is passed in, these three parameters will be ignored.
    Parameter and Description: Object.
    Attribute
    Type
    Required
    Description
    src
    string
    Yes
    The path of the video file, which can either be a temporary file path or a permanent file path.
    quality
    string
    Yes
    Compression quality, whose valid values are:
    Low: Low power
    Medium: Moderate power
    High: High power
    bitrate
    number
    Yes
    Bitrate, measured in kbps.
    fps
    number
    Yes
    Frame rate
    resolution
    number
    Yes
    Resolution ratio relative to the original video, with the value range of (0, 1].
    success
    function
    No
    Callback Function of Successful Interface Call
    fail
    function
    No
    Callback Function of Failing Interface Call
    complete
    function
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    tempFilePath
    string
    Address of the temporary file after compression.
    size
    string
    Size after compression, measured in kB.

    chooseMedia

    This method is used via wx.chooseMedia(Object object).
    Feature Description: Captures or selects images or videos from the mobile phone's album.
    Parameter and Description: Object
    Attribute
    Type
    Default value
    Required
    Description
    count
    number
    9
    No
    The maximum number of files that can be selected. Prior to the V2.25.0 base library, up to 9 files could be supported. From V2.25.0 onwards, up to 20 files can be supported.
    mediaType
    Array.<string>
    ['image','video']
    No
    File type, whose valid values are:
    Image: Only capture images or select images from the album.
    Video: Only capture videos or select videos from the album.
    Mix: Simultaneous selection of images and videos is allowed.
    sourceType
    Array.<string>
    ['album', 'camera']
    No
    The source of image and video selection, whose valid values are:
    Album: Select from album
    Camera: Uses the camera for photographing
    maxDuratuib
    number
    10
    No
    Whether to compress the selected files. Prior to the V2.25.0 base library, this is only effective when mediaType is image. From V2.25.0 onwards, it is applicable to all mediaTypes.
    camera
    string
    ‘back’
    No
    Effective only when sourceType is set to camera, either the front or rear camera. Valid values include:
    Back: Use the rear camera.
    Front: Use the front camera.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    tempFiles
    Array.<Object>
    List of local temporary files
    type
    string
    File type, whose valid values include image, video, and mix.
    Structure attribute of tempFiles
    Structure attributes
    Type
    Description
    tempFilePath
    string
    Local temporary file path (local direct)
    size
    number
    Size of local temporary files, measured in bytes.
    duration
    number
    Duration of video
    height
    number
    Video height
    width
    number
    Video width
    thumbTempFilePath
    string
    Temporary file path of video thumbnail
    fileType
    string
    File type, whose valid values are:
    Image
    Video
    Sample Code
    wx.chooseMedia({
    count: 9,
    mediaType: ['image','video'],
    sourceType: ['album', 'camera'],
    maxDuration: 30,
    camera: 'back',
    success(res) {
    console.log(res.tempFiles.tempFilePath)
    console.log(res.tempFiles.size)
    }
    })

    VideoContext

    Feature Description: VideoContext instance, which can be obtained through wx.createVideoContext. VideoContext is bound to a <video> component through its id, and operates the corresponding <video> component.
    Sample Code
    Corresponding WXML file:
    <view class="section tc">
    <video
    id="myVideo"
    src="https://qzonestyle.gtimg.cn/qzone/qzact/act/external/qq-video/qq-video.mp4"
    enable-danmu
    danmu-btn
    controls
    ></video>
    <view class="btn-area">
    <input bindblur="bindInputBlur" />
    <button bindtap="bindSendDanmu">Dispatch the barrage</button>
    </view>
    </view>
    Corresponding js file:
    function getRandomColor() {
    const rgb = []
    for (let i = 0; i < 3; ++i) {
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
    }
    return '#' + rgb.join('')
    }
    
    Page({
    onReady(res) {
    this.videoContext = wx.createVideoContext('myVideo')
    },
    inputValue: '',
    bindInputBlur(e) {
    this.inputValue = e.detail.value
    },
    bindSendDanmu() {
    this.videoContext.sendDanmu({
    text: this.inputValue,
    color: getRandomColor(),
    })
    },
    })

    Method Set

    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support