spz-video
Layouts
跳转到“Layouts”Usage
跳转到“Usage”In the following example, we use the <source>
tag to embed the video and the custom button to play or pause the video.
<spz-video
id="video"
layout="fixed"
width="1280"
height="720"
poster="https://img.staticdj.com/211c85ff837b770b26e1a1b9d0eb1552.jpeg"
loop
object-fit="cover"
>
<source src="https://videodelivery.net/cdcff94587ee1048c2dd0ce0abe64c28/downloads/default.mp4" type="video/mp4">
</spz-video>
<button type="button" @tap="video.play();">Play</button>
<button type="button" @tap="video.pause();">Pause</button>
Attributes
跳转到“Attributes”src
跳转到“src”The URL of the video to embed must be HTTPS.
This attribute is optional. You may instead use the <source>
element within the video block to specify the video to embed.
poster
跳转到“poster”required
Set the poster image of the video.
autoplay
跳转到“autoplay”If this attribute is present, the video automatically begins to play back as soon as.
loop
跳转到“loop”If this attribute is present, the browser will automatically seek back to the start upon reaching the end of the video.
object-fit
跳转到“object-fit”Set the object-fit
style to embed the video, just like object-fit
CSS property.
object-position
跳转到“object-position”Set the object-position
style to embed the video, just like object-position
CSS property.
zoom
跳转到“zoom”If this attribute is present, enable zoom mode.
Actions
跳转到“Actions”play
跳转到“play”To play the video. No parameter required.
pause
跳转到“pause”To pause the video. No parameter required.
seekTo
跳转到“seekTo”seekTo(currentTime=<Number>)
Seek to a given time. It has the following parameters:
currentTime
: a second number. set a time to seek.
<button type="button" @tap="video.seekTo(currentTime=20);">Seek 20 seconds</button>
Events
跳转到“Events”play
跳转到“play”Be triggered when the video is playing.
pause
跳转到“pause”Be triggered when the video is pausing.
ended
跳转到“ended”Be triggered when the video ends.
enterFull
跳转到“enterFull”Be triggered when the video enters full-screen with the full-screen button.
exitFull
跳转到“exitFull”Be triggered when the video exits full-screen with the full-screen button.
<div id="play">The video is playing.</div>
<spz-video
layout="fixed"
width="1280"
height="720"
poster="https://img.staticdj.com/211c85ff837b770b26e1a1b9d0eb1552.jpeg"
@play="play.show"
@pause="play.hide"
@ended="..."
@enterFull="..."
@exitFull="..."
>
<!-- ... -->
</spz-video>