يقدم هذا المقال طريقة تنفيذ مشغل فيديو 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; -block } #content{ Display: flex } /* player*/ #video{ Display: inline-block: 0; border: 12px Solid #eee; حجم الصندوق: border-box; } .video-list-wrap{ لون الخلفية: #eee; حجم الصندوق: مربع الحدود؛ الهامش: 0؛ العرض: 150 بكسل؛ نمط القائمة: لا شيء؛ عنصر القائمة*/ .video-item{ cursor: pointer; width: 150px; ){ border-bottom: 1px Solid #fff } .video-item:hover, .active{ لون الخلفية: #ddd; color: #333; } /* عنوان قائمة الفيديو*/ .video-title{ الخلفية-الحجم: 12px height: 30px; > </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 id=video control>'); $video.attr('preload', 'auto'); $video.attr('width', 720).attr('height', 405); ', 'autoplay'); $video.append($('<source>').attr('src', src).attr('type', 'video/mp4')); $content.append($video }; /* الحصول على قائمة الفيديو*/ var $video_list = $('.video-list'); ); $.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'); .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'); 'active'); init($this.data('path') });
video.list
# جميع ملفات MP4 الموجودة في هذا الدليل لـ jQuery لتحليلها root@tianshl:/data/video# ls *.mp4 > video.list
تكوين نجينكس
user root;worker_processes 1;events {worker_connections 1024;}http { include mime.types; keepalive_timeout 65; auth_basic_user_file /usr/local/nginx/passwd.db; # جذر المسار /data/video # فهرس المنزل Index.html } }};عرض الواجهة
http://localhost:8000
شهادة
لاعب
ما ورد أعلاه هو المحتوى الكامل لهذه المقالة وآمل أن يكون مفيدًا لدراسة الجميع وآمل أيضًا أن يدعم الجميع شبكة VeVb Wulin.