国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

實(shí)現(xiàn)簡易html視頻播放器的方法

2019-10-26 17:21:25
字體:
供稿:網(wǎng)友

本文介紹了實(shí)現(xiàn)簡易html視頻播放器的方法,分享給大家,具體如下:

文件列表

root@tianshl:/data/video# lshch.mp4 test.mp4 xyx.mp4 index.html video.list jquery.js

index.html

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <style type="text/css"> body{ text-align: center; } #content-wrap{ margin-top: 50px; display: inline-block; } #content{ display: flex; } /* 播放器 */ #video{ display: inline-block; margin: 0; border: 12px solid #eee; box-sizing: border-box; } .video-list-wrap{ background-color: #eee; border-right: 1px solid #fff; } /* 視頻列表 */ .video-list{ display: inline-block; box-sizing: border-box; margin: 0; width: 150px; list-style: none; padding: 0; overflow: auto; font-size: 12px; } /* 列表項(xiàng) */ .video-item{ cursor: pointer; width: 150px; box-sizing: border-box; text-align: left; padding: 5px 0 5px 10px; } .video-item:not(:last-child){ border-bottom: 1px solid #fff; } .video-item:hover, .active{ background-color: #ddd; color: #333; } /* 視頻列表標(biāo)題 */ .video-title{ background-color: gainsboro; font-size: 12px; height: 30px; line-height: 30px; text-align: center; } </style> </head> <body> <div id="content-wrap"> <div id="content"> <div class="video-list-wrap"> <p class="video-title">視頻列表</p> <ul class="video-list"></ul> </div> </div> </div> </body> <script type="text/javascript" src="./jquery.js"></script> <script type="text/javascript"> $(function(){ var $content = $('#content'); // 初始化播放器 var init = function(src){ var $video = $('<video id="video" controls>'); $video.attr('preload', 'auto'); $video.attr('width', 720).attr('height', 405); $video.attr('autoplay', 'autoplay'); $video.append($('<source>').attr('src', src).attr('type', 'video/mp4')); $content.append($video); }; /* 獲取視頻列表 */ var $video_list = $('.video-list'); $video_list.css('height', 340); $.ajax({ url: "video.list", type: "GET", async: true, success: function(resp){ $.each(resp.split('/n'), function(idx, item){ if (item === '') return; var $p = $('<li>').addClass('video-item'); $p.text(item); $p.data('path', item); $video_list.append($p); }); } }); init(); /* 切換視頻 */ $video_list.on('click', '.video-item', function(){ $("#video").remove(); var $this = $(this); $this.parent().find('.active').removeClass('active'); $this.addClass('active'); init($this.data('path')); }); }) </script> </html>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 宜州市| 南雄市| 太保市| 巴林左旗| 金寨县| 米易县| 万载县| 昭苏县| 右玉县| 舞钢市| 荥阳市| 成都市| 婺源县| 河津市| 云林县| 常德市| 句容市| 基隆市| 托里县| 沙洋县| 吴忠市| 盐源县| 北宁市| 威海市| 永寿县| 丰原市| 石嘴山市| 策勒县| 高陵县| 冕宁县| 新丰县| 泰宁县| 花垣县| 胶南市| 靖宇县| 邻水| 澄江县| 汤阴县| 绥江县| 贵州省| 隆子县|