{"id":846,"date":"2025-09-13T23:22:52","date_gmt":"2025-09-13T23:22:52","guid":{"rendered":"https:\/\/www.youtubehack.jp\/?p=846"},"modified":"2025-09-13T23:28:56","modified_gmt":"2025-09-13T23:28:56","slug":"%e3%83%af%e3%82%a4%e3%83%97%e3%82%b3%e3%83%b3%e3%83%88%e3%83%ad%e3%83%bc%e3%83%ab003","status":"publish","type":"post","link":"https:\/\/www.youtubehack.jp\/?p=846","title":{"rendered":"\u30ef\u30a4\u30d7\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb003"},"content":{"rendered":"\n<!-- \u25bc A\u30a8\u30ea\u30a2\uff1a\u30e1\u30a4\u30f3\u52d5\u753b -->\n<div id=\"main-container\" style=\"position:relative; width:640px; height:360px; background:#000;\">\n  <div id=\"main-player\"><\/div>\n\n  <!-- \u25bc \u30ef\u30a4\u30d7\u7528\u30b3\u30f3\u30c6\u30ca -->\n  <div id=\"wipe-container\" style=\"\n      position:absolute;\n      bottom:10px; right:10px;\n      width:200px; height:112px;\n      background:#000;\n      border:2px solid #fff;\n      border-radius:8px;\n      overflow:hidden;\n      display:none;  \/* \u521d\u671f\u306f\u975e\u8868\u793a *\/\n  \">\n    <div id=\"wipe-player\"><\/div>\n\n    <!-- \u25bc \u30af\u30ea\u30c3\u30af\u7121\u52b9\u5316\u7528\u306e\u900f\u660e\u30ab\u30d0\u30fc -->\n    <div id=\"wipe-cover\" style=\"\n        position:absolute;\n        top:0; left:0;\n        width:100%; height:100%;\n        background:transparent;\n        z-index:2;\">\n    <\/div>\n  <\/div>\n<\/div>\n\n<script>\n\/* --- \u65e2\u5b58\u5909\u6570\u306e\u5148\u982d\u306b\u3053\u308c\u3092\u8ffd\u52a0\u3057\u3066\u304a\u304f --- *\/\nvar mainPlayer, wipePlayer;\nvar currentWipe = null;\nvar monitorInterval = null; \/\/ \u76e3\u8996 interval \u3092\u30b0\u30ed\u30fc\u30d0\u30eb\u7ba1\u7406\n\nconst WIPES = [\n  { id: 'M7lc1UVf-VE', start: 5,  end: 15 },\n  { id: 'Yxep-gS-Btg', start: 20, end: 30 },\n  { id: 'bL5hJEauvu4', start: 35, end: 45 }\n];\n\n\/* onYouTubeIframeAPIReady \u306f\u305d\u306e\u307e\u307e\uff08\u30d7\u30ec\u30a4\u30e4\u30fc\u751f\u6210\uff09 *\/\n\n\/* --- onMainStateChange \u306e\u4fee\u6b63\u7248 --- *\/\nfunction onMainStateChange(event) {\n  if (event.data === YT.PlayerState.PLAYING) {\n    \/\/ \u76e3\u8996\u304c\u672a\u4f5c\u6210\u306a\u3089\u958b\u59cb\n    if (!monitorInterval) monitorMain();\n\n    \/\/ \u30e1\u30a4\u30f3\u518d\u751f \u2192 \u73fe\u5728\u8868\u793a\u4e2d\u306e\u30ef\u30a4\u30d7\u304c\u3042\u308c\u3070\u30ef\u30a4\u30d7\u3092\u518d\u958b\n    if (currentWipe && wipePlayer && wipePlayer.getPlayerState) {\n      try {\n        var st = wipePlayer.getPlayerState();\n        \/\/ \u518d\u751f\u4e2d\u3067\u306a\u3051\u308c\u3070\u518d\u751f\u3059\u308b\n        if (st !== YT.PlayerState.PLAYING) {\n          \/\/ seekTo \u306f\u4e0d\u8981\u306a\u3089\u7701\u7565\u3001\u5fc5\u8981\u306a\u3089 uncomment\n          \/\/ wipePlayer.seekTo(currentWipe.start, true);\n          wipePlayer.playVideo();\n        }\n      } catch (e) {\n        console.warn('wipe play error on resume', e);\n      }\n    }\n  } else if (event.data === YT.PlayerState.PAUSED) {\n    \/\/ \u30e1\u30a4\u30f3\u4e00\u6642\u505c\u6b62 \u2192 \u30ef\u30a4\u30d7\u3082\u4e00\u6642\u505c\u6b62\n    if (wipePlayer && wipePlayer.pauseVideo) {\n      try { wipePlayer.pauseVideo(); } catch(e){ console.warn(e); }\n    }\n    \/\/ \u76e3\u8996\u505c\u6b62\n    if (monitorInterval) { clearInterval(monitorInterval); monitorInterval = null; }\n  } else if (event.data === YT.PlayerState.ENDED) {\n    \/\/ \u7d42\u4e86 \u2192 \u30ef\u30a4\u30d7\u505c\u6b62\u30fb\u96a0\u3059\u30fb\u76e3\u8996\u505c\u6b62\n    if (wipePlayer && wipePlayer.stopVideo) {\n      try { wipePlayer.stopVideo(); } catch(e){ console.warn(e); }\n    }\n    document.getElementById('wipe-container').style.display = 'none';\n    if (monitorInterval) { clearInterval(monitorInterval); monitorInterval = null; }\n    currentWipe = null;\n  }\n}\n\n\/* --- monitorMain \u306e\u4fee\u6b63\u7248 --- *\/\nfunction monitorMain() {\n  \/\/ \u65e2\u306b interval \u304c\u4f5c\u3089\u308c\u3066\u3044\u305f\u3089\u30af\u30ea\u30a2\u3057\u3066\u304b\u3089\u4f5c\u308a\u76f4\u3059\uff08\u5b89\u5168\u7b56\uff09\n  if (monitorInterval) { clearInterval(monitorInterval); monitorInterval = null; }\n\n  monitorInterval = setInterval(function() {\n    if (!mainPlayer || mainPlayer.getPlayerState() !== YT.PlayerState.PLAYING) {\n      \/\/ \u518d\u751f\u3067\u306a\u304f\u306a\u3063\u305f\u3089\u76e3\u8996\u505c\u6b62\uff08\u4fdd\u967a\uff09\n      clearInterval(monitorInterval);\n      monitorInterval = null;\n      return;\n    }\n\n    var t = mainPlayer.getCurrentTime();\n\n    \/\/ \u6642\u9593\u306b\u5408\u3046\u30ef\u30a4\u30d7\u3092\u63a2\u3059\n    var match = WIPES.find(w => t >= w.start && t < w.end);\n\n    if (match) {\n      \/\/ \u65b0\u3057\u3044\u30ef\u30a4\u30d7\u306b\u5207\u308a\u66ff\u3048\u308b\u5834\u5408\n      if (!currentWipe || currentWipe.id !== match.id) {\n        currentWipe = match;\n        document.getElementById('wipe-container').style.display = 'block';\n        \/\/ load \u3057\u3066\u3059\u3050 play \u3092\u8a66\u307f\u308b\n        try {\n          wipePlayer.loadVideoById({ videoId: match.id, startSeconds: match.start });\n          \/\/ playVideo \u306f load \u306e\u76f4\u5f8c\u306b\u547c\u3093\u3067\u3082\u826f\u3044\uff08\u30d7\u30ec\u30a4\u30e4\u30fc\u6e96\u5099\u6e08\u307f\u306a\u3089\uff09\n          setTimeout(function(){\n            try { wipePlayer.playVideo(); } catch(e){ \/* silent *\/ }\n          }, 200);\n        } catch (e) {\n          console.warn('wipe load error', e);\n        }\n      } else {\n        \/\/ \u540c\u3058\u30ef\u30a4\u30d7\u304c\u65e2\u306b\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u518d\u751f\u4e2d\u3067\u306a\u3051\u308c\u3070\u518d\u751f\u3059\u308b\n        try {\n          var st = wipePlayer.getPlayerState();\n          if (st !== YT.PlayerState.PLAYING) {\n            wipePlayer.playVideo();\n          }\n        } catch (e) {\n          \/\/ getPlayerState \u304c\u4f7f\u3048\u306a\u3044\u5834\u5408\u306f\u7121\u8996\n        }\n      }\n    } else {\n      \/\/ \u30ef\u30a4\u30d7\u6642\u9593\u5916\u306a\u3089\u975e\u8868\u793a\u30fb\u505c\u6b62\n      if (currentWipe) {\n        try { wipePlayer.stopVideo(); } catch(e){ \/* ignore *\/ }\n        document.getElementById('wipe-container').style.display = 'none';\n        currentWipe = null;\n      }\n    }\n  }, 300); \/\/ 300ms \u3054\u3068\u306b\u30c1\u30a7\u30c3\u30af\uff08\u5fdc\u7b54\u6027\u3092\u4e0a\u3052\u308b\uff09\n}\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-846","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/posts\/846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=846"}],"version-history":[{"count":3,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/posts\/846\/revisions"}],"predecessor-version":[{"id":849,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=\/wp\/v2\/posts\/846\/revisions\/849"}],"wp:attachment":[{"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youtubehack.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}