soiz1 commited on
Commit
8b06cde
·
1 Parent(s): 4816b51

Update index.html

Browse files
Files changed (1) hide show
  1. 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
- document.addEventListener('visibilitychange', async () => {
1133
- if (document.hidden && !document.pictureInPictureElement && !video.paused) {
1134
- try {
1135
- await video.requestPictureInPicture();
1136
- } catch (err) {
1137
- console.error('PiP起動エラー:', err);
 
 
 
 
 
 
 
 
 
 
 
 
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
  });