HTML simply select a video and play it

Relevant knowledge about html player: Rookie tutorial
To select a video file and play it
Insert image description here
Code: Note that jquery is required

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
    
    
            $("#File").change(function (file) {
    
    
                $("body").append(file.target.files[0]);
                var url = window.URL.createObjectURL(file.target.files[0]);
                $("#player")[0].src = url;
                $("#player")[0].onload = function () {
    
    
                    window.URL.revokeObjectURL(src);
                };
                $("#player").css({
    
     "width": "100%", "height": "100%" });
            });
        });
    </script>
</head>
<body>
    <input id="File" type="file" id="file" />
    <video id="player"autoplay="autoplay" controls>
                    </video>
</body>
</html>

When the video cannot be played successfully, you may encounter encoding problems: Solution
1. Download Format Factory
2. Convert video format
Insert image description here

Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/Cream_Cicilian/article/details/129042511