mirror of
https://github.com/gosticks/PiPer.git
synced 2026-07-07 16:30:02 +00:00
Added video module
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
import { info, error } from './logger.js'
|
||||
import { videoPlayingPictureInPicture, togglePictureInPicture } from './video.js'
|
||||
import { localizedButtonTitle } from './localization.js'
|
||||
|
||||
/**
|
||||
@@ -73,8 +74,7 @@ const addButton = function(parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mode = video.webkitPresentationMode == 'picture-in-picture' ? 'inline' : 'picture-in-picture';
|
||||
video.webkitSetPresentationMode(mode);
|
||||
togglePictureInPicture(video);
|
||||
});
|
||||
|
||||
info('Picture in Picture button created');
|
||||
@@ -123,7 +123,7 @@ const videoPresentationModeChanged = function(event) {
|
||||
if (video != expectedVideo) return;
|
||||
|
||||
// Toggle display of the captions and prepare video if needed
|
||||
showingCaptions = video.webkitPresentationMode == 'picture-in-picture';
|
||||
showingCaptions = videoPlayingPictureInPicture(video);
|
||||
if (showingCaptions) prepareCaptions(video);
|
||||
lastUnprocessedCaption = '';
|
||||
processCaptions();
|
||||
@@ -993,7 +993,7 @@ const resources = {
|
||||
removeCaptions(video);
|
||||
};
|
||||
const navigateFinish = function() {
|
||||
showingCaptions = video.webkitPresentationMode == 'picture-in-picture';
|
||||
showingCaptions = videoPlayingPictureInPicture(video);
|
||||
};
|
||||
window.addEventListener('spfrequest', navigateStart);
|
||||
window.addEventListener('spfdone', navigateFinish);
|
||||
|
||||
25
src/common/scripts/video.js
Normal file
25
src/common/scripts/video.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { info } from './logger.js'
|
||||
|
||||
/**
|
||||
* Toggles video Picture in Picture
|
||||
*
|
||||
* @param {HTMLVideoElement} video - video element to toggle Picture in Picture mode
|
||||
*/
|
||||
export const togglePictureInPicture = function(video) {
|
||||
const playingPictureInPicture = videoPlayingPictureInPicture(video);
|
||||
if (playingPictureInPicture) {
|
||||
video.webkitSetPresentationMode('inline');
|
||||
} else {
|
||||
video.webkitSetPresentationMode('picture-in-picture');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if video is playing Picture in Picture
|
||||
*
|
||||
* @param {HTMLVideoElement} video - video element to test
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const videoPlayingPictureInPicture = function(video) {
|
||||
return video.webkitPresentationMode == 'picture-in-picture';
|
||||
};
|
||||
@@ -10,7 +10,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string></string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>163</string>
|
||||
<string>164</string>
|
||||
<key>Developer Identifier</key>
|
||||
<string>BQ6Q24MF9X</string>
|
||||
<key>URL</key>
|
||||
|
||||
Reference in New Issue
Block a user