tencent cloud

Feedback

Media Component

Last updated: 2024-12-19 16:39:59

    audio

    Feature description:Audio component. This component is no longer maintained; it is recommended to use wx.createInnerAudioContext instead.
    Parameter and description:
    Property
    Type
    Default value
    ‍Required
    Description
    id
    string
    -
    False
    The unique identifier for the audio component.
    src
    string
    -
    False
    URL of the audio resource to be played.
    loop
    boolean
    false
    False
    Whether to loop the playback.
    controls
    boolean
    false
    False
    Whether to show the default controls.
    poster
    string
    -
    False
    Image URL for the audio cover on the default controls. This is ignored if controls is set to false.
    name
    string
    Unknown song
    False
    Name of the audio on the default controls. This is ignored if controls is set to false.
    author
    string
    Unknown author
    False
    Author of the audio on the default controls. This is ignored if controls is set to false.
    binderror
    eventhandle
    -
    False
    Triggered when an error occurs, detail = {errMsg: MediaError.code}.
    bindplay
    eventhandle
    -
    False
    Triggered when playback starts or resumes.
    bindpause
    eventhandle
    -
    False
    Triggered when playback is paused.
    bindtimeupdate
    eventhandle
    -
    False
    Triggered when the playback progress changes, detail = {currentTime, duration}.
    bindended
    eventhandle
    -
    False
    Triggered when playback reaches the end.
    Example:
    WXML
    JAVASCRIPT
    <!-- audio.wxml -->
    <audio poster="{{poster}}" name="{{name}}" author="{{author}}" src="{{src}}" id="myAudio" controls loop></audio>
    
    <button type="primary" bindtap="audioPlay">Playback</button>
    <button type="primary" bindtap="audioPause">Pause</button>
    <button type="primary" bindtap="audio14">Sets the current playback time to 14 seconds</button>
    <button type="primary" bindtap="audioStart">Back to the beginning</button>
    // audio.js
    Page({
    onReady: function (e) {
    // Uses wx.createAudioContext to get the audio context
    this.audioCtx = wx.createAudioContext('myAudio')
    },
    data: {
    poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
    name: 'At The Moment',
    author: 'Xu Wei',
    src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&amp;uin=346897220&amp;vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&amp;fromtag=46',
    },
    audioPlay: function () {
    this.audioCtx.play()
    },
    audioPause: function () {
    this.audioCtx.pause()
    },
    audio14: function () {
    this.audioCtx.seek(14)
    },
    audioStart: function () {
    this.audioCtx.seek(0)
    }
    })

    image

    Feature description:Image component.
    Parameter and description:
    Property
    Type
    Default value
    Description
    src
    string
    -
    URL of the image resource.
    mode
    string
    'scaleToFill'
    Mode for image cropping and scaling.
    show-menu-by-longpress
    boolean
    false
    Shows a menu with options like "Save image" when the image is long-pressed.
    lazy-load
    boolean
    false
    Lazy loading of images. Effective only for images within page and scroll-view.
    binderror
    handleevent
    -
    Event name published to AppService when an error occurs, event.detail = {errMsg: 'something wrong'}.
    bindload
    handleevent
    -
    Event name published to AppService when the image is fully loaded, event.detail = {height:'Image height in px', width:'Image width in px'}.
    Notes:
    The default width of the image component is 300 px, and the default height is 225 px.
    When the image component is scaled, the calculated width and height may include decimals, which might be rounded in different webview kernels.
    Valid values for mode: There are 13 modes, including 4 scaling modes and 9 cropping modes.
    Mode
    Value
    Description
    Scaling
    scaleToFill
    Scales the image without preserving the aspect ratio, stretching it to fill the image element completely.
    Scaling
    aspectFit
    Scales the image while preserving the aspect ratio, ensuring the entire image is visible (long side fits).
    Scaling
    aspectFill
    Scales the image while preserving the aspect ratio, ensuring the short side fits, potentially cropping the long side.
    Scaling
    widthFix
    Keeps the width unchanged and adjusts the height automatically, preserving the original aspect ratio.
    Cropping
    top
    Does not scale the image, only shows the top part.
    Cropping
    bottom
    Does not scale the image, only shows the bottom part.
    Cropping
    center
    Does not scale the image, only shows the center part.
    Cropping
    left
    Does not scale the image, only shows the left part.
    Cropping
    right
    Does not scale the image, only shows the right part.
    Cropping
    top left
    Does not scale the image, only shows the top-left corner.
    Cropping
    top right
    Does not scale the image, only shows the top-right corner.
    Cropping
    bottom left
    Does not scale the image, only shows the bottom-left corner.
    Cropping
    bottom right
    Does not scale the image, only shows the bottom-right corner.
    Example:
    WXML
    JAVASCRIPT
    <view class="page">
    <view class="page__hd">
    <text class="page__title">image</text>
    <text class="page__desc">Image</text>
    </view>
    <view class="page__bd">
    <view class="section section_gap" wx:for="{{array}}" wx:for-item="item">
    <view class="section__title">{{item.text}}</view>
    <view class="section__ctn">
    <image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="{{item.mode}}" src="{{src}}"></image>
    </view>
    </view>
    </view>
    </view>
    Page({
    data: {
    array: [{
    mode: 'scaleToFill',
    text: 'scaleToFill: Scales the image without preserving the aspect ratio, stretching it to fill the image element completely. '
    }, {
    mode: 'aspectFit',
    text: 'aspectFit: Scales the image while preserving the aspect ratio, ensuring the entire image is visible (long side fits).'
    }, {
    mode: 'aspectFill',
    text: 'aspectFill: Scales the image while preserving the aspect ratio, ensuring the short side fits, potentially cropping the long side.'
    }, {
    mode: 'top',
    text: 'top: Does not scale the image, only shows the top part.'
    }, {
    mode: 'bottom',
    text: 'bottom: Does not scale the image, only shows the bottom part.'
    }, {
    mode: 'center',
    text: 'center: Does not scale the image, only shows the center part.'
    }, {
    mode: 'left',
    text: 'left: Does not scale the image, only shows the left part.'
    }, {
    mode: 'right',
    text: 'right: Does not scale the image, only shows the right part.'
    }, {
    mode: 'top left',
    text: 'top left: Does not scale the image, only shows the top-left part.'
    }, {
    mode: 'top right',
    text: 'top right: Does not scale the image, only shows the top-right part.'
    }, {
    mode: 'bottom left',
    text: 'bottom left: Does not scale the image, only shows the bottom-left part.'
    }, {
    mode: 'bottom right',
    text: 'bottom right: Does not scale the image, only shows the top-right part.'
    }],
    src: 'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg'
    },
    imageError: function(e) {
    console.log('An error event is triggered in image3, and the carried value is', e.detail.errMsg)
    }
    })

    video

    Feature description:Video component. The component in an earlier version is a Native Component be aware of the limitations of native components when using it.
    Property
    Type
    Default value
    Description
    src
    string
    -
    URL of the video resource to be played, supports cloud file ID.
    duration
    number
    -
    Specifies the video duration.
    controls
    boolean
    true
    Whether to display the default playback controls (play/pause buttons, progress bar, time).
    danmu-list
    Object Array
    -
    List of on-screen comments.
    danmu-btn
    boolean
    false
    Whether to display the on-screen comment button. This configuration is only effective if set during initialization and cannot be changed later.
    enable-danmu
    boolean
    false
    Whether to display the on-screen comments. This configuration is only effective if set during initialization and cannot be changed later.
    autoplay
    boolean
    false
    Whether to enable auto-playback.
    loop
    boolean
    false
    Whether to loop the playback.
    muted
    boolean
    false
    Whether to mute the playback.
    initial-time
    number
    -
    Specifies the initial playback position of the video.
    page-gesture
    boolean
    false
    Whether to enable brightness and volume adjustment gesture in non-full screen mode.
    direction
    number
    -
    Specifies the orientation of the video in full screen mode. If not specified, it is automatically determined based on the aspect ratio.
    0 for normal vertical.
    90 for counterclockwise 90 degrees.
    -90 for clockwise 90 degrees.
    show-progress
    boolean
    true
    If not specified, the progress will only be displayed when the width is greater than 240.
    show-fullscreen-btn
    boolean
    true
    Whether to show the full screen button.
    show-play-btn
    boolean
    true
    Whether to show the playback button in the control bar at the bottom of the video.
    show-center-play-btn
    boolean
    true
    Whether to show the playback button in the middle of the video.
    enable-progress-gesture
    boolean
    true
    Whether to enable the gesture to control progress.
    object-fit
    string
    contain
    The presentation format of a video when the size of the video does not match the video container size.
    contain: Contain.
    fil: Fill.
    cover: Cover.
    poster
    string
    -
    URL or cloud file ID for the video cover image. Settings to the poster are ineffective if the property value of controls is set to false.
    show-mute-btn
    boolean
    false
    Whether to show the mute button.
    title
    string
    -
    Title of the video, displayed at the top in fullscreen.
    play-btn-position
    string
    bottom
    The position of the playback button. Valid values:
    bottom (on the control bar)
    center (in the center of the video)
    enable-play-gesture
    boolean
    false
    Whether to enable the playback gesture, i.e., double tap to switch between playback and pause.
    auto-pause-if-navigate
    boolean
    true
    Whether to automatically pause the video on this page when navigating to another mini program page.
    auto-pause-if-open-native
    boolean
    true
    Whether to automatically pause the video on this page when navigating to another native page.
    vslide-gesture
    boolean
    false
    Whether to enable brightness and volume adjustment gesture in non-full screen mode (same as page-gesture).
    vslide-gesture-in-fullscreen
    boolean
    true
    Whether to enable brightness and volume adjustment gesture in full screen mode.
    picture-in-picture-mode
    string/Array
    -
    Sets picture-in-picture mode: push, pop, or an array of modes (e.g., ["push", "pop"]).
    enable-auto-rotation
    boolean
    false
    Whether to enable automatic fullscreen when the phone is rotated, effective when system auto-rotate is enabled.
    bindplay
    eventhandle
    -
    Triggered when playback starts or resumes.
    bindpause
    eventhandle
    -
    Triggered when playback is paused.
    bindended
    eventhandle
    -
    Triggered when playback reaches the end.
    bindtimeupdate
    eventhandle
    -
    Triggered when playback progress changes, event.detail = {currentTime, duration}. Trigger frequency: 250 ms.
    bindfullscreenchange
    eventhandle
    -
    Triggered when the video enters/exits full screen mode; event.detail = {fullScreen, direction}. Valid values: vertical, horizontal.
    bindwaiting
    eventhandle
    -
    Triggered when the video is buffering.
    binderror
    eventhandle
    -
    Triggered when an error occurs during video playback.
    bindprogress
    eventhandle
    -
    Triggered when the loading progress changes. supports only one segment of loading. event.detail = {buffered},in percentage.
    bindloadedmetadata
    eventhandle
    -
    Triggered when the video metadata is loaded. event.detail = {width, height, duration}
    Notes:
    <video>The default width is 300 px and the default height is 225 px. You can set the width and height using wxss.
    Picture-in-picture feature description:
    The video component supports the following three trigger modes for picture-in-picture (PiP) (set via the picture-in-picture-mode property):
    push mode: PiP appears when navigating from the current page to the next page (page stack push).
    pop mode: PiP is triggered when leaving the current page (page stack pop).
    Both of these routing behaviors will trigger PiP.
    Additionally, PiP supports the following features:
    The size of the PiP container is automatically determined based on the original component size.
    Tapping on the PiP will navigate the user back to the page containing the corresponding video player.
    After PiP appears, users can close it by tapping the close button in the top right corner of the PiP or by calling the context.exitPictureInPicture() method.
    When the player enters PiP mode, the page containing the player will enter the hide state (triggering the onHide lifecycle event) but will not be destroyed. When the PiP is closed, the page containing the player will be unloaded (triggering the onUnload lifecycle event).
    Example:
    WXML
    JAVASCRIPT
    <view class="page-body">
    <view class="page-section tc">
    &lt;video
    id="myVideo"
    src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&amp;bizid=1023&amp;hy=SH&amp;fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"
    binderror="videoErrorCallback"
    danmu-list="{{danmuList}}"
    enable-danmu
    danmu-btn
    show-center-play-btn='{{false}}'
    show-play-btn="{{true}}"
    controls
    picture-in-picture-mode="{{['push', 'pop']}}"
    bindenterpictureinpicture='bindVideoEnterPictureInPicture'
    bindleavepictureinpicture='bindVideoLeavePictureInPicture'
    ></video>
    <view style="margin: 30rpx auto" class="weui-label">On-screen comment content</view>
    <input bindblur="bindInputBlur" class="weui-input" type="text" placeholder="Type your on-screen comment here" />
    <button style="margin: 30rpx auto" bindtap="bindSendDanmu" class="page-body-button" type="primary" formType="submit">Send on-screen comment</button>
    <navigator style="margin: 30rpx auto" url="picture-in-picture" hover-class="other-navigator-hover">
    <button type="primary" class="page-body-button" bindtap="bindPlayVideo">Picture-in-picture mode</button>
    </navigator>
    </view>
    </view>
    function getRandomColor() {
    const rgb = []
    for (let i = 0; i &lt; 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({
    onShareAppMessage() {
    return {
    title: 'video',
    path: 'page/component/pages/video/video'
    }
    },
    
    onReady() {
    this.videoContext = wx.createVideoContext('myVideo')
    },
    
    onHide() {
    
    },
    
    inputValue: '',
    data: {
    src: '',
    danmuList:
    [{
    text: 'The on-screen comment that appears in the first second',
    color: '#ff0000',
    time: 1
    }, {
    text: 'The on-screen comment that appears in the third second',
    color: '#ff00ff',
    time: 3
    }],
    },
    
    bindInputBlur(e) {
    this.inputValue = e.detail.value
    },
    
    bindButtonTap() {
    const that = this
    wx.chooseVideo({
    sourceType: ['album', 'camera'],
    maxDuration: 60,
    camera: ['front', 'back'],
    success(res) {
    that.setData({
    src: res.tempFilePath
    })
    }
    })
    },
    
    bindVideoEnterPictureInPicture() {
    console.log('Enters picture-in-picture mode')
    },
    
    bindVideoLeavePictureInPicture() {
    console.log ('Exits picture-in-picture mode')
    },
    
    bindPlayVideo() {
    console.log('1')
    this.videoContext.play()
    },
    bindSendDanmu() {
    this.videoContext.sendDanmu({
    text: this.inputValue,
    color: getRandomColor()
    })
    },
    
    videoErrorCallback(e) {
    console.log ('Video error message: ')
    console.log(e.detail.errMsg)
    }
    })
    

    animation-video

    Feature description:The animation-video component is a frontend component that allows mini programs to render specific video resources with a transparent background, enabling developers to create immersive and rich animation effects at a low cost. The animation-video component also provides a variety of APIs to control the animation's playback, pause, jump to a specified position, and more. For related APIs, see wx.createAnimationVideoContext.
    Parameter and description:
    Property
    Type
    Default value
    ‍Required
    Description
    resource-width
    number
    800
    False
    The width of the video resource used by the component (unit: px).
    resource-height
    number
    400
    False
    The height of the video resource used by the component (unit: px).
    canvas-style
    string
    width:400px;
    height:400px;
    False
    CSS styles for animation canvas.
    path
    string
    
    True
    URL of the animation resource, supports relative and remote paths. If it is a remote path,Access-Control-Allow-Origin needs to be set in the response header to prevent cross-origin issues.
    loop
    boolean
    false
    False
    Whether to loop the animation playback.
    autoplay
    boolean
    false
    False
    Whether to enable auto-playback for the animations.
    alpha-direction
    string
    left
    False
    Direction of the alpha channel in the video resource. left means the alpha channel is on the left side, right means it is on the right side.
    bindstarted
    eventhandle
    -
    False
    The callback is triggered when the animation starts playing.
    bindended
    eventhandle
    -
    False
    Event triggered when the animation reaches the end (natural end of playback triggers the callback, loop end and pause do not trigger it).
    Example:
    WXML
    JAVASCRIPT
    <view class="wrap">
    <view class="card-area">
    <view class="top-description border-bottom">
    <view>Animation alpha channel information is on the right side of the video</view>
    <view>alpha-direction='right'</view>
    </view>
    <view class="video-area">
    &lt;animation-video
    path="{{rightAlphaSrcPath}}"
    loop="{{loop}}"
    resource-width="800"
    resource-height="400"
    canvas-style="width:200px;height:200px"
    autoplay="{{autoplay}}"
    bindstarted="onStarted"
    bindended="onEnded"
    alpha-direction='right'
    ></animation-video>
    </view>
    </view>
    
    
    <view class="card-area">
    <view class="top-description border-bottom">
    <view>Animation alpha channel information is on the left side of the video</view>
    <view>alpha-direction='left'</view>
    </view>
    <view class="video-area">
    &lt;animation-video
    path="{{leftAlphaSrcPath}}"
    loop="{{loop}}"
    resource-width="800"
    resource-height="400"
    canvas-style="width:200px;height:200px"
    autoplay="{{autoplay}}"
    bindstarted="onStarted"
    bindended="onEnded"
    alpha-direction='left'
    ></animation-video>
    </view>
    </view>
    </view>
    Page({
    data: {
    loop: true,
    leftAlphaSrcPath: 'https://efe-h2.cdn.bcebos.com/ceug/resource/res/2020-1/1577964961344/003e2f0dcd81.mp4',
    rightAlphaSrcPath: 'https://b.bdstatic.com/miniapp/assets/docs/alpha-right-example.mp4',
    autoplay: true
    },
    onStarted() {
    console.log('===onStarted');
    },
    onEnded() {
    console.log('===onEnded');
    }
    })
    

    camera

    Feature description:System camera. This component is a Native Component and there are some restrictions for using it. For related APIs, see wx.createCameraContext.
    Parameter and description:
    Property
    Type
    Valid values
    Default value
    Description
    mode
    string
    normal: Camera mode
    ScanCode: Scan code mode
    normal
    Application mode. This configuration is only effective if set during initialization and cannot be changed later.
    device-position
    string
    front: Front-facing
    back: Rear-facing
    back
    Camera position.
    flash
    string
    auto: Auto
    on: Enabled
    off: Disabled
    torch: Always on
    auto
    Flash. Valid values: auto, on, off.
    bindstop
    eventhandle
    -
    -
    Triggered when the camera stops abnormally, such as exiting the background.
    binderror
    eventhandle
    -
    -
    Triggered when the user denies camera access.
    bindscancode
    eventhandle
    -
    -
    Triggered when a scan code is successfully recognized, only effective when mode="scanCode".
    Notes:
    User authorization is required for scope.camera.
    Only one camera component can be inserted to a page.
    The onCameraFrame API returns raw frame data of different sizes based on frame-size, which may differ from the image displayed by the camera component. The actual pixel values are determined by the system.
    Example:
    WXML
    JAVASCRIPT
    &lt;camera
    device-position="back"
    flash="off"
    binderror="error"
    style="width: 100%; height: 300px;"
    ></camera>
    <button type="primary" bindtap="takePhoto">Camera</button>
    <view>Preview</view>
    <image mode="widthFix" src="{{src}}"></image>
    Page({
    takePhoto() {
    const ctx = wx.createCameraContext()
    ctx.takePhoto({
    quality: 'high',
    success: (res) => {
    this.setData({
    src: res.tempImagePath
    })
    }
    })
    },
    error(e) {
    console.log(e.detail)
    }
    })

    live-player

    Feature description:Real-time playback of audios and videos. This component is a native component, and there are some restrictions for using it. For details, see Native Components.
    Parameter and description:
    Property
    Type
    Valid values
    Default value
    Description
    src
    string
    -
    -
    URL of the audios and videos. Only flv and rtmp formats are supported.
    mode
    string
    live: Live streaming
    RTC: Real-time call
    live
    The mode.
    autoplay
    boolean
    -
    false
    Auto-playback.
    muted
    boolean
    -
    false
    Whether the audios and videos are muted.
    orientation
    string
    vertical: Portrait
    horizontal: Landscape
    vertical
    Screen orientation.
    object-fit
    string
    contain: Image's long side fills the screen, short side areas are black.
    fillCrop: Image fills the screen, excess parts are cropped.
    contain
    Fill mode. Valid values: contain, fillCrop.
    min-cache
    number
    -
    1
    Minimum buffer size in seconds (0.2 seconds is recommended for the RTC mode).
    max-cache
    number
    -
    3
    Maximum buffer size in seconds (0.8 seconds is recommended for the RTC mode). The buffer is used to resist network fluctuations. Larger buffer improves network stability but increases latency.
    sound-mode
    string
    speaker: Speaker
    ear: Earphone
    speaker
    Sound output mode.
    auto-pause-if-navigate
    boolean
    -
    true
    Whether to automatically pause the live audio and video on this page when navigating to another mini program page.
    auto-pause-if-open-native
    boolean
    -
    true
    Whether to automatically pause the live audio and video on this page when navigating to another native page of the host app.
    picture-in-picture-mode
    string/Array
    []: Disable the picture-in-picture.
    push: Trigger the picture-in-picture when routing push is performed
    pop: Trigger the picture-in-picture when routing pop is performed
    -
    Sets the picture-in-picture mode: push, pop, or an array of modes (e.g., ["push", "pop"]).
    enable-auto-rotation
    boolean
    -
    false
    Whether to enable automatic full-screen when the phone is rotated, effective when system auto-rotate is enabled.
    enable-metadata
    boolean
    -
    false
    Whether to call back metadata.
    bindstatechange
    eventhandle
    -
    -
    Triggered when playback state changes, detail = {code}.
    bindfullscreenchange
    eventhandle
    -
    -
    Triggered when full-screen mode changes, detail = {direction, fullScreen}.
    bindnetstatus
    eventhandle
    -
    -
    Network status notification, detail = {info}.
    bindaudiovolumenotify
    eventhandle
    -
    -
    Playback volume notification, detail = {}.
    bindenterpictureinpicture
    eventhandle
    -
    -
    Triggered when the player enters PiP mode.
    bindleavepictureinpicture
    eventhandle
    -
    -
    Triggered when the player exits PiP mode.
    bindmetadatachange
    eventhandle
    -
    -
    Metadata notification, detail = {info}.
    Status code
    Code
    Description
    2001
    Connected to the server successfully.
    2002
    Connected to the server and started the stream pulling.
    2003
    The network received the first video data packet (IDR).
    2004
    Video playback started.
    2006
    Video playback ended.
    2007
    Video playback is loading.
    2008
    Decoder started.
    2009
    Video resolution changed.
    -2301
    The network is disconnected, and automatic reconnection fails multiple times. Please restart the playback manually.
    -2302
    Failed to get accelerated stream URL.
    2101
    Failed to decode the current video frame.
    2102
    Failed to decode the current audio frame.
    2103
    The network is disconnected, and automatic reconnection has been started.
    2104
    Unstable incoming network packets. This may be caused by insufficient downstream bandwidth, or uneven outbound traffic from the source.
    2105
    Video freezes occurred during playback.
    2106
    Hardware decoding failed, switching to software decoding.
    2107
    Current video frames are not continuous, possible frame loss.
    2108
    The first I-frame hardware decoding failed, SDK automatically switches to software decoding.
    3001
    RTMP - DNS resolution failed.
    3002
    RTMP server connection failed.
    3003
    RTMP server handshake failed.
    3005
    RTMP read/write failed.
    Network status data
    Key name
    Description
    videoBitrate
    Current video data reception bit rate (in kbps).
    audioBitrate
    Current audio data reception bit rate (in kbps).
    videoFPS
    Current video frame rate.
    videoGOP
    Current video GOP (Group of pictures), i.e., the time interval between every two keyframes (I frames) (unit: s).
    netSpeed
    Current sending/receiving speed.
    netJitter
    Network jitter, with higher values indicating less stable network conditions.
    videoWidth
    Width of the video image.
    videoHeight
    Height of the video image.
    Notes:
    The default width of live-player is 300 px and the default height is 225 px. You can set the width and height using wxss.
    This component is not supported on developer tools.
    Picture-in-picture feature description:
    The video component supports the following three trigger modes for picture-in-picture (PiP) (set via the picture-in-picture-mode property):
    push mode: PiP appears when navigating from the current page to the next page (page stack push).
    pop mode: PiP is triggered when leaving the current page (page stack pop).
    Both of these routing behaviors will trigger PiP.
    Additionally, PiP supports the following features:
    The size of the PiP container is automatically determined based on the original component size.
    Tapping on the PiP will navigate the user back to the page containing the corresponding video player.
    After PiP appears, users can close it by tapping the close button in the top right corner of the PiP or by calling the context.exitPictureInPicture() method.
    When the player enters PiP mode, the page containing the player will enter the hide state (triggering the onHide lifecycle event) but will not be destroyed. When the PiP is closed, the page containing the player will be unloaded (triggering the onUnload lifecycle event).
    Example:
    WXML
    JAVASCRIPT
    &lt;live-player
    src="https://domain/pull_stream"
    mode="RTC"
    autoplay
    bindstatechange="statechange"
    binderror="error"
    style="width: 300px; height: 225px;"
    />
    Page({
    statechange(e) {
    console.log('live-player code:', e.detail.code)
    },
    error(e) {
    console.error('live-player error:', e.detail.errMsg)
    }
    })

    live-pusher

    Feature description:The live-pusher component is used for real-time audio and video recording (same-layer rendering is not supported).
    Parameter and description:
    Property
    Type
    Valid values
    Default value
    Description
    url
    string
    -
    -
    Stream URL. Only RTMP is supported.
    mode
    string
    -
    RTC
    SD (Standard Definition), HD (High Definition), FHD (Full High Definition), RTC (Real-Time Communication).
    autopush
    boolean
    -
    false
    Automatic stream pushing.
    muted
    boolean
    -
    false
    Whether the audios and videos are muted.
    enable-camera
    boolean
    -
    true
    Enable the camera.
    auto-focus
    boolean
    -
    true
    Auto focus.
    orientation
    string
    vertical: Portrait
    horizontal: Landscape
    vertical
    Screen orientation.
    beauty
    number
    -
    0
    Beauty filter. Value range: 0-9, where 0 indicates off.
    whiteness
    number
    -
    0
    Whiteness filter. Value range: 0-9, where 0 indicates off.
    aspect
    string
    -
    9:16
    Aspect ratio. Valid values: 3:4, 9:16.
    min-bitrate
    number
    -
    200
    Min bitrate.
    max-bitrate
    number
    -
    1000
    Max bitrate.
    audio-quality
    string
    -
    height
    High quality (48 kHz) or low quality (16 kHz). Valid values: high, low.
    waiting-image
    string
    -
    -
    Waiting image when the app goes to the background.
    waiting-image-hash
    string
    -
    -
    The MD5 value of the waiting image resource.
    zoom
    boolean
    -
    false
    Adjusts the zoom.
    device-position
    string
    -
    -
    Camera position. Valid values: front, back.
    background-mute
    boolean
    -
    false
    Whether to mute the sound when entering the background.
    mirror
    boolean
    -
    false
    Whether mirror the push stream, reflected in the live-player.
    local-mirror
    string
    auto: Front camera mirrors, back camera does not
    enable: Both front and rear cameras mirror
    disable: Neither camera mirrors
    auto
    Controls local preview mirroring.
    audio-reverb-type
    number
    0: Disable
    1: KTV
    2: Small room
    3: Auditorium
    4: Deep
    5: Loud
    6: Metal
    7: Magnetic
    0
    Types of audio reverberation.
    enable-mic
    boolean
    -
    -
    Enable or disable the microphone.
    enable-agc
    boolean
    -
    false
    Whether to enable audio automatic gain control (AGC).
    enable-ans
    boolean
    -
    false
    Whether to enable audio noise suppression.
    audio-volume-type
    string
    auto: Auto
    media: Media volume
    voicecall: Call volume
    auto
    Volume type.
    video-width
    number
    -
    360
    Resolution width of the pushed video stream.
    video-height
    number
    -
    640
    Resolution height of the pushed video stream.
    bindstatechange
    eventhandle
    -
    -
    Status change event, detail = {code}.
    bindnetstatus
    eventhandle
    -
    -
    Network status notification, detail = {info}.
    binderror
    eventhandle
    -
    -
    Render error event, detail = {errMsg, errCode}.
    bindbgmstart
    eventhandle
    -
    -
    Triggered when the background sound starts playing.
    bindbgmprogress
    eventhandle
    -
    -
    Triggered when the background sound progress changes, detail = {progress, duration}.
    bindbgmcomplete
    eventhandle
    -
    -
    Triggered when the background sound finished playing.
    Notes:
    User authorization is required for scope.camera and scope.record.
    This component is not supported on developer tools.
    The default width of live-pusher is 100%, and there is no default height. Please set the width and height using wxss.
    Error code
    Code
    Description
    10001
    User has denied access to the camera.
    10002
    User has denied access to the microphone.
    10003
    Failed to load the background music (BGM) resource.
    10004
    Failed to load the waiting image resource (waiting-image).
    Status code
    Code
    Description
    1001
    Connected to the stream pushing server.
    1002
    Completed handshake with the server and started stream pushing.
    1003
    Enabled the camera successfully.
    1004
    Started screen recording successfully.
    1005
    Dynamic resolution adjustment during streaming.
    1006
    Dynamic bitrate adjustment during streaming.
    1007
    Captured the first frame successfully.
    1008
    Started the encoder successfully.
    -1301
    Failed to enable the camera.
    -1302
    Failed to enable the microphone.
    -1303
    Failed to encode the video.
    -1304
    Failed to encode the audio.
    -1305
    Unsupported video resolution.
    -1306
    Unsupported audio sample rate.
    -1307
    The network is disconnected, and automatic reconnection fails multiple times. Please restart the stream pushing manually.
    -1308
    Failed to start the screen recording. Possible reason: Rejected by the user.
    -1309
    Screen recording failed. Reason: Unsupported Android version (5.0 or above version is required).
    -1310
    Screen recording is interrupted by another application.
    -1311
    Enabled Android microphone successfully, but no audio data captured.
    -1312
    Failed to switch between landscape and portrait screens during screen recording.
    1101
    Poor network conditions: Insufficient uplink bandwidth, data upload obstructed.
    1102
    The network is disconnected, and automatic reconnection has been started.
    1103
    Hardware decoding failed, switching to software decoding.
    1104
    Failed to encode the video.
    3001
    RTMP - DNS resolution failed.
    3002
    RTMP server connection failed.
    3003
    RTMP server handshake failed.
    3004
    RTMP server disconnected, please check the validity of the stream URL or anti-leech link expiration.
    3005
    RTMP read/write failed.
    Network status data
    Key name
    Description
    videoBitrate
    Current video encoder output bit rate (in kbps).
    audioBitrate
    Current audio encoder output bit rate (in kbps).
    videoFPS
    Current video frame rate.
    videoGOP
    Current video GOP, i.e., the time interval between every two keyframes (I frames) (unit: s).
    netSpeed
    Current sending/receiving speed.
    netJitter
    Network jitter, with higher values indicating less stable network conditions.
    videoWidth
    Width of the video image.
    videoHeight
    Height of the video image.
    Example:
    WXML
    JAVASCRIPT
    &lt;live-pusher
    url="https://domain/push_stream"
    mode="RTC"
    autopush
    bindstatechange="statechange"
    style="width: 300px; height: 225px;"
    />
    Page({
    statechange(e) {
    console.log('live-pusher code:', e.detail.code)
    }
    })
    
    
    
    
    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