Update index.html
Browse files- index.html +18 -6
index.html
CHANGED
@@ -1129,12 +1129,24 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
1129 |
video.preservesPitch = true;
|
1130 |
video.mozPreservesPitch = true; // Firefox用
|
1131 |
video.webkitPreservesPitch = true; // 古いWebKit用
|
1132 |
-
|
1133 |
-
if (document.hidden
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1138 |
}
|
1139 |
}
|
1140 |
});
|
|
|
1129 |
video.preservesPitch = true;
|
1130 |
video.mozPreservesPitch = true; // Firefox用
|
1131 |
video.webkitPreservesPitch = true; // 古いWebKit用
|
1132 |
+
document.addEventListener('visibilitychange', async () => {
|
1133 |
+
if (document.hidden) {
|
1134 |
+
// 他のタブに移動したとき → PiP起動
|
1135 |
+
if (!document.pictureInPictureElement && !video.paused) {
|
1136 |
+
try {
|
1137 |
+
await video.requestPictureInPicture();
|
1138 |
+
} catch (err) {
|
1139 |
+
console.error('PiP開始失敗:', err);
|
1140 |
+
}
|
1141 |
+
}
|
1142 |
+
} else {
|
1143 |
+
// ページに戻ってきたとき → PiPを閉じる
|
1144 |
+
if (document.pictureInPictureElement) {
|
1145 |
+
try {
|
1146 |
+
await document.exitPictureInPicture();
|
1147 |
+
} catch (err) {
|
1148 |
+
console.error('PiP終了失敗:', err);
|
1149 |
+
}
|
1150 |
}
|
1151 |
}
|
1152 |
});
|