Functions as a video player.
The HTTP, HTTPS, and RTSP protocols are supported. When mainstream video compression standards such as H.263, H.264, and MPEG-4 and mainstream audio coding formats such as AAC, FLAC, and MP3 are adopted, mainstream container formats such as MPEG-4 (.mp4), 3GPP (.3gp), MPEG-TS (.ts, not seekable), Matroska (.mkv), and Ogg (.ogg) are supported.
Item | Description |
|---|---|
Applicable devices | Mobile phones, tablets, Vision products, and telematics devices |
Applicable regions | Global |
In addition to general attributes and text, the attributes listed in the following table are supported.
Attribute | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
muted (1030+) | boolean | false | No | Indicates whether a video is played in mute mode. |
src | uri | - | No | URI of the video playback content. The value can be an absolute or a relative path. For details about the URI, please refer to URI. CAUTION: The URI cannot contain parameters with Chinese characters in them. Otherwise, an error will occur during video playback. |
autoplay | boolean | false | No | Indicates whether a video is played automatically after being rendered. |
poster | uri | - | No | Preview poster of a video. |
controls | boolean | true | No | Indicates whether to display the video control bar. The value false indicates no. The default value true indicates that the platform determines whether to display or hide the control bar. |
orientation (1070+) | string | landscape | No | Page orientation used when the video is displayed in full-screen mode. When a user taps the full-screen button of the control, if this parameter is set to landscape, the video is played in landscape mode. If this parameter is set to portrait, the video is played in portrait mode. |
titlebar (1072+) | boolean | true | No | Indicates whether to display the title bar when a video is played in full-screen mode.
The title bar is not displayed when a video is not played in full-screen mode. When controls is set to false, the setting of this parameter does not take effect. |
title (1072+) | string | - | No | Title displayed in the title bar during full-screen playback. Only one line of text is supported. If the text length exceeds the limit, the text is automatically truncated by an ellipsis (...). |
playcount (1080+) | integer | 1 | No | Number of times a video should play. The value can be infinite. |
In addition to common styles, the style listed in the following table is supported.
Style | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
object-fit (1035+) | contain | cover | fill | none | scale-down | contain | No | Indicates how a video is resized. If poster is set, this parameter also applies to the video poster. |
Types of the object-fit style (1035+)
Type | Description |
|---|---|
cover | Resize a video while keeping its aspect ratio so that both dimensions of the video will be greater than or equal to the dimension of the view and place the video to the center. |
contain | Resize a video while keeping its aspect ratio so that both dimensions of the video will be less than or equal to the dimension of the view and place the video to the center. |
fill | Resize an image without keeping its aspect ratio to fill the view. |
none | Resize a video while keeping its original aspect ratio. |
scale-down | The effect of this style is similar to that after you set the style to none and contain in sequence. Finally, the image with a smaller size is displayed. |
The swipe event is not supported. In versions earlier than 1040, a click event is not triggered when the video playback control bar is tapped. In addition to common events, the events listed in the following table are supported.
Event | Parameter | Triggering Condition |
|---|---|---|
prepared | - | A video is connected successfully. |
start | - | A video is played. This event can be triggered only once if minPlatform configured in the manifest.json file is greater than or equal to 1076. Otherwise, the trigger times are not restricted. |
pause | - | Video playback is paused. |
finish | - | Video playback ends. |
error | - | Playback fails. |
seeking | {currenttime: value(second)} | The seeking time is reported when a user drags the progress bar. |
seeked | {currenttime: value(second)} | The playing time is reported when a user drops the progress bar. |
timeupdate | {currenttime: value(second)} | The playing progress changes. This event is triggered every 250 ms. |
fullscreenchange | {fullscreen: fullscreenValue} | A video enters or exits the full-screen mode. |
Method | Parameter | Description |
|---|---|---|
start | - | Starts playing a video. |
pause | - | Pauses a video. |
setCurrentTime | {currenttime: value(second)} | Specifies the video playing position. |
requestFullscreen (1050+) | { screenOrientation : "portrait" | "landscape" } | Requests to enter the full-screen mode. If the value of minPlatformVersion is less than 1050, the default value is landscape. Otherwise, the default value is portrait. |
exitFullscreen | - | Exits the full-screen mode. |
In some scenarios, you may need to display the custom elements such as the buttons for switching image quality and sharing the video when the video is played in full screen.
Such feature is supported since version 1080. To implement the feature:
For details, please refer to enablevideofullscreencontainer.
<template>
<div class="container">
<div class="page-title-wrap">
<text class="page-title">{{componentName}}</text>
</div>
<div class="item-container">
<text class="item-title">Play MP4 format</text>
<stack id="stackDemo01" class="s1">
<video id="video" style="width:{{twidth}};height:{{theight}}" poster="https://www.quickapp.cn/assets/images/home/video.png" orientation="portrait" onprepared="prepared" onstart="start" onpause="pause" onfinish="finish" onerror="error" onseeking="eventSeeking" onseeked="eventSeeked" ontimeupdate="eventTimeupdate" src="https://ss0.bdstatic.com/-0U0bnSm1A5BphGlnYG/cae-legoup-video-target/93be3d88-9fc2-4fbd-bd14-833bca731ca7.mp4" @fullscreenchange="onFullscreenchange" controls="{{showControls}}" muted="{{muted}}" titlebar="{{titlebar}}" title="Quick APP Introduction video"></video>
<div class="d1">
<text style="color:#7fffd4;flex:1">stack Add overlay</text>
<input type="button" class="btn" value="exit full screen" onclick="exitFullScreen" />
</div>
</stack>
</div>
<div class="item-container">
<input type="button" class="btn" value="play" onclick="btnstart" />
</div>
<div class="item-container">
<input type="button" class="btn" value="pause" onclick="btnpause" />
</div>
<div class="item-container">
<input type="button" class="btn" value="seek" onclick="btnSeek" />
</div>
<div class="item-container">
<input type="button" class="btn" value="full landscape" onclick="btnEnterFullLandscape" />
</div>
<div class="item-container">
<input type="button" class="btn" value="full portrait" onclick="btnEnterFullPortrait" />
</div>
<div class="item-container">
<input type="button" class="btn" value="show or hide contorls" onclick="switchShowControls" />
</div>
<div class="item-container">
<input type="button" class="btn" value="show or hide title" onclick="switchShowtitle" />
</div>
<div class="item-container">
<input type="button" class="btn" value="stack full screen" onclick="requestStackFullscreen" />
</div>
</div>
</template>
<style>
.container {
flex: 1;
flex-direction: column;
}
.page-title-wrap {
padding-top: 50px;
padding-bottom: 80px;
justify-content: center;
}
.page-title {
padding-top: 30px;
padding-bottom: 30px;
padding-left: 40px;
padding-right: 40px;
border-color: #bbbbbb;
color: #bbbbbb;
border-bottom-width: 2px;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
.d1 {
flex-direction: column;
margin-bottom: 20px;
}
.s1 {
height: 350px;
}
.item-title {
padding-left: 30px;
padding-bottom: 20px;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
margin-right: 60px;
margin-left: 60px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
</style>
<script>
import prompt from '@system.prompt'
export default {
data: {
componentName: 'video',
showmask: true,
showicon: true,
ignorenet: false,
showControls: true,
muted: false,
objectFitValues: [
'cover', 'contain', 'fill', 'none', 'scale-down'
],
objectFitClass: '',
fullScreen: false,
titlebar: true,
twidth: '100%',
theight: '100%'
},
onInit() {
this.$page.setTitleBar({ text: 'video' })
},
prepared: function () {
console.log("play")
prompt.showToast({ message:"play"})
},
start: function () {
console.log("play")
prompt.showToast({ message: "play" })
},
pause: function () {
console.log("pause")
prompt.showToast({ message:"pause" })
},
finish: function () {
console.log("finish play")
prompt.showToast({ message: "finish play" })
},
error: function () {
console.log("play error")
prompt.showToast({ message:"play error"})
},
eventSeeking: function (e) {
let msg = "event:" + 'Seeking to ' + e.currenttime
console.log(msg)
prompt.showToast({ message: msg })
},
eventSeeked: function (e) {
let msg = "event:" + 'Seeked to ' + e.currenttime
console.log(msg)
prompt.showToast({ message: msg })
},
eventTimeupdate: function (e) {
let msg = "event:"+ 'Timeupdate : ' + e.currenttime
console.log(msg)
if (e.currenttime === 10) {
this.$element('video').requestFullscreen()
} else if (e.currenttime === 20) {
this.$element('video').exitFullscreen()
}
},
eventFullscreenchange: function (e) {
let msg = "event:" + 'Fullscreenchange : ' + e.fullscreen
console.log(msg)
prompt.showToast({ message: msg })
this.fullScreen = true
},
btnstart: function () {
this.$element('video').start()
prompt.showToast({ message: "Click the play button to start playing" })
},
btnpause: function () {
this.$element('video').pause()
prompt.showToast({ message: "Click the pause button to pause playback" })
},
btnSeek: function () {
this.$element('video').setCurrentTime({ currenttime: 60 })
prompt.showToast({ message: "seek 60" })
},
btnEnterFullLandscape: function () {
this.$element('video').requestFullscreen({ screenOrientation: 'landscape' })
prompt.showToast({ message: 'requestFullscreen landscape' })
},
btnEnterFullPortrait() {
this.$element('video').requestFullscreen({ screenOrientation: 'portrait' })
prompt.showToast({ message: 'requestFullscreen portrait' })
},
onFullscreenchange(data) {
this.fullScreen = data.fullscreen
},
switchShowControls(e) {
this.showControls = !this.showControls
},
onMutedSwitched(e) {
this.muted = e.checked
},
onMulchSwitched(e) {
this.$element('stackDemo01').requestFullscreen({ screenOrientation: 'landscape' })
},
changeOption(e) {
this.objectFitClass = e.newValue
prompt.showToast({ message: 'object-fit Successfully switched' })
},
switchShowtitle() {
this.titlebar = !this.titlebar
},
requestStackFullscreen() {
this.$element('stackDemo01').requestFullscreen({ 'screenOrientation': 'landscape' })
},
exitFullScreen() {
this.$element('video').exitFullscreen()
this.twidth = '100%'
this.theight = '100%'
}
}
</script> The following figure shows the final effect.

Version | Date | Description |
|---|---|---|
1080 | 2021-12-28 |
|
1070 | 2020-05-19 | Added the orientation attribute to control the page orientation when the video enters the full-screen mode. |
1050 | 2019-09-20 | Added the requestFullscreen method to request to enter the full-screen mode. |
1030 | 2018-10-31 | Added the muted attribute to determine whether to mute video during playback. |
1010 | 2018-04-20 | Added the controls attribute to determine whether to display or hide the video playback control bar. |