Comments: Although HTML 5 video can be used to display controls and pause playback, different browsers may display different effects, we will share with you the following information about using Dom to perform custom operations and control HTML5 video. Although controls can be used to display controls and control playing pause, however, different browsers may display different effects, so we often need to use Dom for custom operations and control. The following is a small example.
Of course, the effect is not very beautiful. If you want to have a good view, you can set your own css style.
The Code is as follows:
<Div id = "video_div" style = "text-align: center;">
<Button onclick = "playPause ()"> play/pause </button>
<Button onclick = "toBig ()"> large </button>
<Button onclick = "toNormal ()"> medium </button>
<Button onclick = "toSmall ()"> small </button>
<Video id = "myVideo" width = "500" height = "250" style = "margin-top: 15px;">
<Source src = "demo.mp4" type = "video/mp4"/>
<Source src = "demo.ogg" type = "video/ogg"/>
Your browser does not support this HTML5 video tag.
</Video>
</Div>
The Code is as follows:
<Script type = "text/javascript">
Var myVideo = document. getElementById ("myVideo ");
Function playPause ()
{
If (myVideo. paused)
MyVideo. play ();
Else
MyVideo. pause ();
}
Function toBig ()
{
MyVideo. width = 560;
}
Function toNormal ()
{
MyVideo. width = 420;
}
Function toSmall ()
{
MyVideo. width = 320;
}
</Script>
Note that only the videoWidth and videoHeight attributes are available immediately in all attributes.
Other attributes are available only after the video metadata has been loaded.