{"id":7430,"date":"2020-09-25T08:59:19","date_gmt":"2020-09-25T00:59:19","guid":{"rendered":"https:\/\/blog.hoyo.idv.tw\/?p=7430"},"modified":"2020-09-25T08:59:19","modified_gmt":"2020-09-25T00:59:19","slug":"video-js-%e5%bd%b1%e7%89%87%e4%b8%b2%e6%b5%81%e9%8c%af%e8%aa%a4%e9%87%8d%e6%96%b0%e6%92%ad%e6%94%be","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=7430","title":{"rendered":"Video.js - \u5f71\u7247\u4e32\u6d41\u932f\u8aa4\u91cd\u65b0\u64ad\u653e"},"content":{"rendered":"<p>\u5916\u9762\u770b\u5230\u7684\u96fb\u8996\u5ee3\u544a\u6a5f\uff0c\u5f71\u7247\u662f\u5982\u4f55\u4e0d\u505c\u64ad\u653e\u53c8\u4e0d\u6703\u56e0\u70ba\u767c\u751f\u932f\u8aa4\u4e2d\u6b62\u64ad\u653e\uff1f\u9019\u662f Hoyo \u7684\u898b\u89e3\u4ee5\u53ca\u89e3\u6c7a\u65b9\u6848<\/p>\n<ul>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/stackoverflow.com\/questions\/53208917\/videojs-settimeout-when-the-video-end\" target=\"_blank\" rel=\"noopener\">VideoJS settimeout when the video end<\/a><\/li>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/stackoverflow.com\/questions\/19896521\/better-way-to-check-for-video-js-object-on-instantiation\" target=\"_blank\" rel=\"noopener\">Better way to check for Video.js object on instantiation?<\/a><\/li>\n<li><a href=\"https:\/\/docs.videojs.com\/docs\/api\/player.html#Eventserror\" target=\"_blank\" rel=\"noopener\">error<\/a><\/li>\n<li><a href=\"https:\/\/docs.videojs.com\/module-videojs-videojs.html#.getAllPlayers\" target=\"_blank\" rel=\"noopener\">getAllPlayers<\/a><\/li>\n<\/ul>\n<p>\u5728\u6b64\u9700\u8981\u4f7f\u7528 2 \u500b\u6a5f\u5236\uff0c\u4e00\u500b\u662f Video.js \u7684 error \u4e8b\u4ef6\uff0c\u53e6\u4e00\u500b\u662f\u53d6\u5f97\u76ee\u524d\u6709\u591a\u5c11\u500b\u5f71\u7247\u64ad\u653e<\/p>\n<pre class=\"lang:js decode:true\">\/\/ \u6bcf 2 \u79d2\u6aa2\u67e5\u4e00\u4e0b\r\nsetInterval(function(){\r\n\r\n    \/\/ \u756b\u9762\u4e0a\u6c92\u6709\u5f71\u7247\u4ee5\u53ca\u9700\u8981\u64ad\u653e\u5f71\u7247\u624d\u6aa2\u67e5\r\n    if ( videojs.getAllPlayers().length ===0 &amp;&amp; video_ready ===1 ) {\r\n        \/\/ \u5c07\u5f71\u7247\u5340\u57df\u64ad\u653e HTML \u91cd\u7f6e\r\n        $('#video_display').html(mp4_video[0].outerHTML);\r\n        \/\/ \u5c07\u5f71\u7247\u7db2\u5740\u586b\u5165 mp4.php \u662f\u56e0\u70ba\u4f7f\u7528\u4e32\u6d41\u64ad\u653e\r\n        $('#video_mp4').find('source').attr('src', 'http:\/\/' + server + '\/mp4.php');\r\n\r\n        player = videojs('video_mp4', {\r\n            \"controls\": false,\r\n            \"autoplay\": true,\r\n            \"loop\": true,\r\n            \"preload\": 'auto'\r\n        });\r\n        \r\n        \/\/ \u5f71\u7247\u6e96\u5099\u5b8c\u6210\u64ad\u653e\u4ee5\u53ca\u8a2d\u5b9a\r\n        player.ready(function () {\r\n            setTimeout(function () {\r\n                player.autoplay('any');\r\n                player.muted(false);\r\n                player.volume(1);\r\n            }, 2000);\r\n        });\r\n\r\n        \/\/ \u5f71\u7247\u767c\u751f\u932f\u8aa4\u6642\u5c07 videojs \u64ad\u653e\u522a\u9664\r\n        player.on('error', function() {\r\n            player.dispose();\r\n        });\r\n    }\r\n\r\n}, 2000);<\/pre>\n<ul>\n<li>\u4f7f\u7528 .dispose() \u6703\u5c07 &lt;video&gt;&lt;\/video&gt; \u522a\u9664\uff0c\u56e0\u6b64\u9700\u8981\u4f7f\u7528 HTML \u91cd\u7f6e\u6062\u5fa9<\/li>\n<li>\u5728\u6b64\u662f\u56e0\u70ba\u4f7f\u7528\u4e32\u6d41\u64ad\u653e\u6709\u53ef\u80fd\u4e00\u958b\u59cb\u53ef\u4ee5\u64ad\u653e\uff0c\u9014\u4e2d\u767c\u751f\u7db2\u8def\u554f\u984c\u5c0e\u81f4\u4e0d\u80fd\u64ad\u653e\uff0c\u624d\u9700\u8981\u6b64\u65b9\u6848\u89e3\u6c7a<\/li>\n<\/ul>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"7430\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,858&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5916\u9762\u770b\u5230\u7684\u96fb\u8996\u5ee3\u544a\u6a5f\uff0c\u5f71\u7247\u662f\u5982...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"7430\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;1,858&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/7430"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7430"}],"version-history":[{"count":1,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/7430\/revisions"}],"predecessor-version":[{"id":7431,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/7430\/revisions\/7431"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}