{"id":101,"date":"2026-09-10T23:30:00","date_gmt":"2026-09-10T15:30:00","guid":{"rendered":"https:\/\/liveroom.cxmdwz.cn\/?page_id=101"},"modified":"2026-09-11T23:00:05","modified_gmt":"2026-09-11T15:00:05","slug":"%e4%ba%8c%e5%8f%b7%e7%ba%bf%e8%b7%af","status":"publish","type":"page","link":"https:\/\/liveroom.cxmdwz.cn\/index.php\/%e4%ba%8c%e5%8f%b7%e7%ba%bf%e8%b7%af\/","title":{"rendered":"\u4e8c\u53f7\u7ebf\u8def"},"content":{"rendered":"\n<h3 id=\"nowr\">null<\/h3>\n<meta charset=\"UTF-8\">\n<div id=\"hds\"><p id=\"onlineCount\"><\/p><\/div>\n<div class=\"my-div\" id=\"nPlayer\"><\/div>\n<script src=\"https:\/\/unpkg.com\/vue@3\/dist\/vue.global.js\"><\/script>\n<script src=\"https:\/\/unpkg.com\/vue@3\/dist\/vue.global.js\"><\/script>\n<script src=\"https:\/\/unpkg.com\/nplayer@latest\/dist\/index.min.js\"><\/script>\n<script src=\"https:\/\/unpkg.com\/@nplayer\/danmaku@latest\/dist\/index.min.js\"><\/script>\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/hls.js\/dist\/hls.min.js\"><\/script>\n   <style>\n        \/* \u63a8\u8350\uff1a\u5168\u5c40\u91cd\u7f6e\u76d2\u6a21\u578b\uff0c\u4f7f\u5bbd\u9ad8\u5305\u542bpadding\u548cborder *\/\n        * {\n            box-sizing: border-box;\n        }\n\n.my-div {\n            width: 100%;   \/* \u56fa\u5b9a\u5bbd\u5ea6 *\/\n            height: 500px;  \/* height: 100vh\u56fa\u5b9a\u9ad8\u5ea6 *\/\n            background-color: #f0f0f0;\n            border: 1px solid #ccc;\n        }\n    <\/style>\n\n<script>\n\n    var wsUrl = \"wss:\/\/ink.cxmdwz.cn:25599\";\nlet t=0;\n\n\n\nconst hls = new Hls()\nconst player = new NPlayer.Player({\n  \n  plugins: [new NPlayerDanmaku({ items: [] })]\n})\nhls.on(Hls.Events.MEDIA_ATTACHED, function () {\n  hls.loadSource('https:\/\/liveroomplayer.cxmdwz.cn\/liveroom\/v2.m3u8')\n})\nhls.attachMedia(player.video)\nplayer.mount('#nPlayer')\n\n\/\/\/ 2. \u5efa\u7acb WebSocket \u8fde\u63a5\nconst ws = new WebSocket(wsUrl);\nconst ws2 = new WebSocket(wsUrl);\n\nws.onopen = () => {\n  console.log('WebSocket \u5df2\u8fde\u63a5')\n  \/\/ \u5982\u9700\u9274\u6743\u6216\u8fdb\u5165\u623f\u95f4\uff0c\u5728\u8fd9\u91cc\u53d1\u9001\n}\nws.addEventListener('open', function (event) {\n  console.log('Connected to the WebSocket server.');\n  \/\/ \u8fde\u63a5\u5efa\u7acb\u540e\u53ef\u4ee5\u7acb\u5373\u53d1\u6d88\u606f\n  \n});\n\nws.onmessage = (e) => {\n  \/\/ 3. \u89e3\u6790\u670d\u52a1\u7aef\u63a8\u9001\u7684\u5f39\u5e55\u6570\u636e\n  const data = JSON.parse(e.data)\n \n  \/\/ \u5047\u8bbe\u670d\u52a1\u7aef\u8fd4\u56de { text, time, color }\n  player.danmaku.appendItems([\n    { time: data.time, text: data.text, color: data.color || '#fff' }\n  ])\n}\n\n\/\/ 4. \u7528\u6237\u53d1\u9001\u5f39\u5e55 \u2192 \u8f6c\u53d1\u7ed9\u670d\u52a1\u7aef\nplayer.on('DanmakuSend', (opts) => {\n  ws.send(JSON.stringify(opts))\n\n})\n\n\n\n ws2.addEventListener('open', function (event) {\n       \n });\nsetInterval(function() {\n    try {\n        ws2.send(\"r\") ;\n} catch (error) {\n        \n    }\n   \n   \n    \n}, 2000); \nws2.onmessage = (event) => {\n  const obj = JSON.parse(event.data);\n  document.getElementById('nowr').textContent=\"\u5f53\u524d\u4eba\u6570\uff1a\"+obj.online;\n};\n\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>null<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-101","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/pages\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":13,"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/pages\/101\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/pages\/101\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/liveroom.cxmdwz.cn\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}