@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/AFK/AFKController.js +109 -109
- package/dist/commonjs/Config/Config.js +559 -559
- package/dist/commonjs/Config/SettingBase.js +98 -98
- package/dist/commonjs/Config/SettingFlag.js +49 -49
- package/dist/commonjs/Config/SettingNumber.js +83 -83
- package/dist/commonjs/Config/SettingOption.js +84 -84
- package/dist/commonjs/Config/SettingText.js +42 -42
- package/dist/commonjs/DataChannel/DataChannelController.js +106 -106
- package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +94 -94
- package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +18 -18
- package/dist/commonjs/DataChannel/DataChannelSender.js +43 -43
- package/dist/commonjs/DataChannel/InitialSettings.js +41 -41
- package/dist/commonjs/DataChannel/LatencyTestResults.js +60 -60
- package/dist/commonjs/FreezeFrame/FreezeFrame.js +93 -93
- package/dist/commonjs/FreezeFrame/FreezeFrameController.js +95 -95
- package/dist/commonjs/Inputs/GamepadController.js +188 -188
- package/dist/commonjs/Inputs/GamepadTypes.js +21 -21
- package/dist/commonjs/Inputs/IInputController.js +2 -2
- package/dist/commonjs/Inputs/InputClassesFactory.js +96 -96
- package/dist/commonjs/Inputs/KeyCodes.js +112 -112
- package/dist/commonjs/Inputs/KeyboardController.js +137 -137
- package/dist/commonjs/Inputs/MouseButtons.js +28 -28
- package/dist/commonjs/Inputs/MouseController.js +97 -97
- package/dist/commonjs/Inputs/MouseControllerHovering.js +93 -93
- package/dist/commonjs/Inputs/MouseControllerLocked.js +153 -153
- package/dist/commonjs/Inputs/SpecialKeyCodes.js +19 -19
- package/dist/commonjs/Inputs/TouchController.js +123 -123
- package/dist/commonjs/Inputs/TouchController.js.map +1 -1
- package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
- package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
- package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
- package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
- package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
- package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
- package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
- package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
- package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
- package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
- package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
- package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
- package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
- package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
- package/dist/commonjs/Util/EventEmitter.js +386 -386
- package/dist/commonjs/Util/FileUtil.js +108 -108
- package/dist/commonjs/Util/IURLSearchParams.js +25 -25
- package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
- package/dist/commonjs/Util/RTCUtils.js +40 -40
- package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
- package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
- package/dist/commonjs/WebXR/WebXRController.js +335 -335
- package/dist/commonjs/pixelstreamingfrontend.js +70 -70
- package/dist/esm/AFK/AFKController.js +105 -105
- package/dist/esm/Config/Config.js +551 -551
- package/dist/esm/Config/SettingBase.js +94 -94
- package/dist/esm/Config/SettingFlag.js +45 -45
- package/dist/esm/Config/SettingNumber.js +79 -79
- package/dist/esm/Config/SettingOption.js +80 -80
- package/dist/esm/Config/SettingText.js +38 -38
- package/dist/esm/DataChannel/DataChannelController.js +102 -102
- package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
- package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
- package/dist/esm/DataChannel/DataChannelSender.js +39 -39
- package/dist/esm/DataChannel/InitialSettings.js +34 -34
- package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
- package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
- package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
- package/dist/esm/Inputs/GamepadController.js +184 -184
- package/dist/esm/Inputs/GamepadTypes.js +17 -17
- package/dist/esm/Inputs/IInputController.js +1 -1
- package/dist/esm/Inputs/InputClassesFactory.js +91 -91
- package/dist/esm/Inputs/KeyCodes.js +109 -109
- package/dist/esm/Inputs/KeyboardController.js +133 -133
- package/dist/esm/Inputs/MouseButtons.js +23 -23
- package/dist/esm/Inputs/MouseController.js +93 -93
- package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
- package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
- package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
- package/dist/esm/Inputs/TouchController.js +119 -119
- package/dist/esm/Inputs/TouchController.js.map +1 -1
- package/dist/esm/Inputs/TouchControllerFake.js +87 -87
- package/dist/esm/Inputs/XRGamepadController.js +120 -120
- package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
- package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
- package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
- package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
- package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
- package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
- package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
- package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
- package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
- package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
- package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
- package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
- package/dist/esm/UI/OnScreenKeyboard.js +78 -78
- package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
- package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
- package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
- package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
- package/dist/esm/Util/EventEmitter.js +345 -345
- package/dist/esm/Util/FileUtil.js +103 -103
- package/dist/esm/Util/IURLSearchParams.js +21 -21
- package/dist/esm/Util/InputCoordTranslator.js +45 -45
- package/dist/esm/Util/RTCUtils.js +36 -36
- package/dist/esm/VideoPlayer/StreamController.js +63 -63
- package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
- package/dist/esm/WebXR/WebXRController.js +331 -331
- package/dist/esm/pixelstreamingfrontend.js +24 -24
- package/dist/types/AFK/AFKController.d.ts +38 -38
- package/dist/types/Config/Config.d.ts +220 -220
- package/dist/types/Config/SettingBase.d.ts +43 -43
- package/dist/types/Config/SettingFlag.d.ts +24 -24
- package/dist/types/Config/SettingNumber.d.ts +41 -41
- package/dist/types/Config/SettingOption.d.ts +41 -41
- package/dist/types/Config/SettingText.d.ts +21 -21
- package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
- package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
- package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
- package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
- package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
- package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
- package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
- package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
- package/dist/types/Inputs/GamepadController.d.ts +61 -61
- package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
- package/dist/types/Inputs/IInputController.d.ts +16 -16
- package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
- package/dist/types/Inputs/KeyCodes.d.ts +5 -5
- package/dist/types/Inputs/KeyboardController.d.ts +34 -34
- package/dist/types/Inputs/MouseButtons.d.ts +22 -22
- package/dist/types/Inputs/MouseController.d.ts +40 -40
- package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
- package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
- package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
- package/dist/types/Inputs/TouchController.d.ts +28 -28
- package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
- package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
- package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
- package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
- package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
- package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
- package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
- package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
- package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
- package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
- package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
- package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
- package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
- package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
- package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
- package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
- package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
- package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
- package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
- package/dist/types/Util/EventEmitter.d.ts +429 -429
- package/dist/types/Util/FileUtil.d.ts +32 -32
- package/dist/types/Util/IURLSearchParams.d.ts +9 -9
- package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
- package/dist/types/Util/RTCUtils.d.ts +8 -8
- package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
- package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
- package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
- package/dist/types/WebXR/WebXRController.d.ts +42 -42
- package/dist/types/pixelstreamingfrontend.d.ts +23 -23
- package/package.json +45 -45
- package/src/Inputs/TouchController.ts +3 -3
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.VideoPlayer = void 0;
|
|
5
|
-
const Config_1 = require("../Config/Config");
|
|
6
|
-
const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
|
|
7
|
-
/**
|
|
8
|
-
* The video player html element
|
|
9
|
-
*/
|
|
10
|
-
class VideoPlayer {
|
|
11
|
-
/**
|
|
12
|
-
* @param videoElementParent the html div the the video player will be injected into
|
|
13
|
-
* @param config the applications configuration. We're interested in the startVideoMuted flag
|
|
14
|
-
*/
|
|
15
|
-
constructor(videoElementParent, config) {
|
|
16
|
-
this.lastTimeResized = new Date().getTime();
|
|
17
|
-
this.videoElement = document.createElement('video');
|
|
18
|
-
this.config = config;
|
|
19
|
-
this.videoElement.id = 'streamingVideo';
|
|
20
|
-
this.videoElement.disablePictureInPicture = true;
|
|
21
|
-
this.videoElement.playsInline = true;
|
|
22
|
-
this.videoElement.style.width = '100%';
|
|
23
|
-
this.videoElement.style.height = '100%';
|
|
24
|
-
this.videoElement.style.position = 'absolute';
|
|
25
|
-
this.videoElement.style.pointerEvents = 'all';
|
|
26
|
-
videoElementParent.appendChild(this.videoElement);
|
|
27
|
-
this.onResizePlayerCallback = () => {
|
|
28
|
-
console.log('Resolution changed, restyling player, did you forget to override this function?');
|
|
29
|
-
};
|
|
30
|
-
this.onMatchViewportResolutionCallback = () => {
|
|
31
|
-
console.log('Resolution changed and match viewport resolution is turned on, did you forget to override this function?');
|
|
32
|
-
};
|
|
33
|
-
// set play for video (and audio)
|
|
34
|
-
this.videoElement.onclick = () => {
|
|
35
|
-
if (this.audioElement != undefined && this.audioElement.paused) {
|
|
36
|
-
this.audioElement.play();
|
|
37
|
-
}
|
|
38
|
-
if (this.videoElement.paused) {
|
|
39
|
-
this.videoElement.play();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
this.videoElement.onloadedmetadata = () => {
|
|
43
|
-
this.onVideoInitialized();
|
|
44
|
-
};
|
|
45
|
-
// set resize events to the windows if it is resized or its orientation is changed
|
|
46
|
-
window.addEventListener('resize', () => this.resizePlayerStyle(), true);
|
|
47
|
-
window.addEventListener('orientationchange', () => this.onOrientationChange());
|
|
48
|
-
}
|
|
49
|
-
setAudioElement(audioElement) {
|
|
50
|
-
this.audioElement = audioElement;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Sets up the video element with any application config and plays the video element.
|
|
54
|
-
* @returns A promise for if playing the video was successful or not.
|
|
55
|
-
*/
|
|
56
|
-
play() {
|
|
57
|
-
this.videoElement.muted = this.config.isFlagEnabled(Config_1.Flags.StartVideoMuted);
|
|
58
|
-
this.videoElement.autoplay = this.config.isFlagEnabled(Config_1.Flags.AutoPlayVideo);
|
|
59
|
-
return this.videoElement.play();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @returns True if the video element is paused.
|
|
63
|
-
*/
|
|
64
|
-
isPaused() {
|
|
65
|
-
return this.videoElement.paused;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @returns - whether the video element is playing.
|
|
69
|
-
*/
|
|
70
|
-
isVideoReady() {
|
|
71
|
-
return this.videoElement.readyState !== undefined && this.videoElement.readyState > 0;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @returns True if the video element has a valid video source (srcObject).
|
|
75
|
-
*/
|
|
76
|
-
hasVideoSource() {
|
|
77
|
-
return this.videoElement.srcObject !== undefined && this.videoElement.srcObject !== null;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the current context of the html video element
|
|
81
|
-
* @returns - the current context of the video element
|
|
82
|
-
*/
|
|
83
|
-
getVideoElement() {
|
|
84
|
-
return this.videoElement;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get the current context of the html video elements parent
|
|
88
|
-
* @returns - the current context of the video elements parent
|
|
89
|
-
*/
|
|
90
|
-
getVideoParentElement() {
|
|
91
|
-
return this.videoElement.parentElement;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Set the Video Elements src object tracks to enable
|
|
95
|
-
* @param enabled - Enable Tracks on the Src Object
|
|
96
|
-
*/
|
|
97
|
-
setVideoEnabled(enabled) {
|
|
98
|
-
// this is a temporary hack until type scripts video element is updated to reflect the need for tracks on a html video element
|
|
99
|
-
const videoElement = this.videoElement;
|
|
100
|
-
videoElement.srcObject
|
|
101
|
-
.getTracks()
|
|
102
|
-
.forEach((track) => (track.enabled = enabled));
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* An override for when the video has been initialized with a srcObject
|
|
106
|
-
*/
|
|
107
|
-
onVideoInitialized() {
|
|
108
|
-
// Default Functionality: Do Nothing
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* On the orientation change of a window clear the timeout
|
|
112
|
-
*/
|
|
113
|
-
onOrientationChange() {
|
|
114
|
-
clearTimeout(this.orientationChangeTimeout);
|
|
115
|
-
this.orientationChangeTimeout = window.setTimeout(() => {
|
|
116
|
-
this.resizePlayerStyle();
|
|
117
|
-
}, 500);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Resizes the player style based on the window height and width
|
|
121
|
-
* @returns - nil if requirements are satisfied
|
|
122
|
-
*/
|
|
123
|
-
resizePlayerStyle() {
|
|
124
|
-
const videoElementParent = this.getVideoParentElement();
|
|
125
|
-
if (!videoElementParent) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
this.updateVideoStreamSize();
|
|
129
|
-
if (videoElementParent.classList.contains('fixed-size')) {
|
|
130
|
-
this.onResizePlayerCallback();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
// controls for resizing the player
|
|
134
|
-
this.resizePlayerStyleToFillParentElement();
|
|
135
|
-
this.onResizePlayerCallback();
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Resizes the player element to fill the parent element
|
|
139
|
-
*/
|
|
140
|
-
resizePlayerStyleToFillParentElement() {
|
|
141
|
-
const videoElementParent = this.getVideoParentElement();
|
|
142
|
-
//Video is not initialized yet so set videoElementParent to size of parent element
|
|
143
|
-
const styleWidth = '100%';
|
|
144
|
-
const styleHeight = '100%';
|
|
145
|
-
const styleTop = 0;
|
|
146
|
-
const styleLeft = 0;
|
|
147
|
-
videoElementParent.setAttribute('style', 'top: ' +
|
|
148
|
-
styleTop +
|
|
149
|
-
'px; left: ' +
|
|
150
|
-
styleLeft +
|
|
151
|
-
'px; width: ' +
|
|
152
|
-
styleWidth +
|
|
153
|
-
'; height: ' +
|
|
154
|
-
styleHeight +
|
|
155
|
-
'; cursor: default;');
|
|
156
|
-
}
|
|
157
|
-
updateVideoStreamSize() {
|
|
158
|
-
if (!this.config.isFlagEnabled(Config_1.Flags.MatchViewportResolution)) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const now = new Date().getTime();
|
|
162
|
-
if (now - this.lastTimeResized > 300) {
|
|
163
|
-
const videoElementParent = this.getVideoParentElement();
|
|
164
|
-
if (!videoElementParent) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
this.onMatchViewportResolutionCallback(videoElementParent.clientWidth, videoElementParent.clientHeight);
|
|
168
|
-
this.lastTimeResized = new Date().getTime();
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
lib_pixelstreamingcommon_ue5_5_1.Logger.Info('Resizing too often - skipping');
|
|
172
|
-
clearTimeout(this.resizeTimeoutHandle);
|
|
173
|
-
this.resizeTimeoutHandle = window.setTimeout(() => this.updateVideoStreamSize(), 100);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
exports.VideoPlayer = VideoPlayer;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.VideoPlayer = void 0;
|
|
5
|
+
const Config_1 = require("../Config/Config");
|
|
6
|
+
const lib_pixelstreamingcommon_ue5_5_1 = require("@epicgames-ps/lib-pixelstreamingcommon-ue5.5");
|
|
7
|
+
/**
|
|
8
|
+
* The video player html element
|
|
9
|
+
*/
|
|
10
|
+
class VideoPlayer {
|
|
11
|
+
/**
|
|
12
|
+
* @param videoElementParent the html div the the video player will be injected into
|
|
13
|
+
* @param config the applications configuration. We're interested in the startVideoMuted flag
|
|
14
|
+
*/
|
|
15
|
+
constructor(videoElementParent, config) {
|
|
16
|
+
this.lastTimeResized = new Date().getTime();
|
|
17
|
+
this.videoElement = document.createElement('video');
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.videoElement.id = 'streamingVideo';
|
|
20
|
+
this.videoElement.disablePictureInPicture = true;
|
|
21
|
+
this.videoElement.playsInline = true;
|
|
22
|
+
this.videoElement.style.width = '100%';
|
|
23
|
+
this.videoElement.style.height = '100%';
|
|
24
|
+
this.videoElement.style.position = 'absolute';
|
|
25
|
+
this.videoElement.style.pointerEvents = 'all';
|
|
26
|
+
videoElementParent.appendChild(this.videoElement);
|
|
27
|
+
this.onResizePlayerCallback = () => {
|
|
28
|
+
console.log('Resolution changed, restyling player, did you forget to override this function?');
|
|
29
|
+
};
|
|
30
|
+
this.onMatchViewportResolutionCallback = () => {
|
|
31
|
+
console.log('Resolution changed and match viewport resolution is turned on, did you forget to override this function?');
|
|
32
|
+
};
|
|
33
|
+
// set play for video (and audio)
|
|
34
|
+
this.videoElement.onclick = () => {
|
|
35
|
+
if (this.audioElement != undefined && this.audioElement.paused) {
|
|
36
|
+
this.audioElement.play();
|
|
37
|
+
}
|
|
38
|
+
if (this.videoElement.paused) {
|
|
39
|
+
this.videoElement.play();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.videoElement.onloadedmetadata = () => {
|
|
43
|
+
this.onVideoInitialized();
|
|
44
|
+
};
|
|
45
|
+
// set resize events to the windows if it is resized or its orientation is changed
|
|
46
|
+
window.addEventListener('resize', () => this.resizePlayerStyle(), true);
|
|
47
|
+
window.addEventListener('orientationchange', () => this.onOrientationChange());
|
|
48
|
+
}
|
|
49
|
+
setAudioElement(audioElement) {
|
|
50
|
+
this.audioElement = audioElement;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sets up the video element with any application config and plays the video element.
|
|
54
|
+
* @returns A promise for if playing the video was successful or not.
|
|
55
|
+
*/
|
|
56
|
+
play() {
|
|
57
|
+
this.videoElement.muted = this.config.isFlagEnabled(Config_1.Flags.StartVideoMuted);
|
|
58
|
+
this.videoElement.autoplay = this.config.isFlagEnabled(Config_1.Flags.AutoPlayVideo);
|
|
59
|
+
return this.videoElement.play();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @returns True if the video element is paused.
|
|
63
|
+
*/
|
|
64
|
+
isPaused() {
|
|
65
|
+
return this.videoElement.paused;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @returns - whether the video element is playing.
|
|
69
|
+
*/
|
|
70
|
+
isVideoReady() {
|
|
71
|
+
return this.videoElement.readyState !== undefined && this.videoElement.readyState > 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @returns True if the video element has a valid video source (srcObject).
|
|
75
|
+
*/
|
|
76
|
+
hasVideoSource() {
|
|
77
|
+
return this.videoElement.srcObject !== undefined && this.videoElement.srcObject !== null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the current context of the html video element
|
|
81
|
+
* @returns - the current context of the video element
|
|
82
|
+
*/
|
|
83
|
+
getVideoElement() {
|
|
84
|
+
return this.videoElement;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the current context of the html video elements parent
|
|
88
|
+
* @returns - the current context of the video elements parent
|
|
89
|
+
*/
|
|
90
|
+
getVideoParentElement() {
|
|
91
|
+
return this.videoElement.parentElement;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set the Video Elements src object tracks to enable
|
|
95
|
+
* @param enabled - Enable Tracks on the Src Object
|
|
96
|
+
*/
|
|
97
|
+
setVideoEnabled(enabled) {
|
|
98
|
+
// this is a temporary hack until type scripts video element is updated to reflect the need for tracks on a html video element
|
|
99
|
+
const videoElement = this.videoElement;
|
|
100
|
+
videoElement.srcObject
|
|
101
|
+
.getTracks()
|
|
102
|
+
.forEach((track) => (track.enabled = enabled));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* An override for when the video has been initialized with a srcObject
|
|
106
|
+
*/
|
|
107
|
+
onVideoInitialized() {
|
|
108
|
+
// Default Functionality: Do Nothing
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* On the orientation change of a window clear the timeout
|
|
112
|
+
*/
|
|
113
|
+
onOrientationChange() {
|
|
114
|
+
clearTimeout(this.orientationChangeTimeout);
|
|
115
|
+
this.orientationChangeTimeout = window.setTimeout(() => {
|
|
116
|
+
this.resizePlayerStyle();
|
|
117
|
+
}, 500);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Resizes the player style based on the window height and width
|
|
121
|
+
* @returns - nil if requirements are satisfied
|
|
122
|
+
*/
|
|
123
|
+
resizePlayerStyle() {
|
|
124
|
+
const videoElementParent = this.getVideoParentElement();
|
|
125
|
+
if (!videoElementParent) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.updateVideoStreamSize();
|
|
129
|
+
if (videoElementParent.classList.contains('fixed-size')) {
|
|
130
|
+
this.onResizePlayerCallback();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// controls for resizing the player
|
|
134
|
+
this.resizePlayerStyleToFillParentElement();
|
|
135
|
+
this.onResizePlayerCallback();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Resizes the player element to fill the parent element
|
|
139
|
+
*/
|
|
140
|
+
resizePlayerStyleToFillParentElement() {
|
|
141
|
+
const videoElementParent = this.getVideoParentElement();
|
|
142
|
+
//Video is not initialized yet so set videoElementParent to size of parent element
|
|
143
|
+
const styleWidth = '100%';
|
|
144
|
+
const styleHeight = '100%';
|
|
145
|
+
const styleTop = 0;
|
|
146
|
+
const styleLeft = 0;
|
|
147
|
+
videoElementParent.setAttribute('style', 'top: ' +
|
|
148
|
+
styleTop +
|
|
149
|
+
'px; left: ' +
|
|
150
|
+
styleLeft +
|
|
151
|
+
'px; width: ' +
|
|
152
|
+
styleWidth +
|
|
153
|
+
'; height: ' +
|
|
154
|
+
styleHeight +
|
|
155
|
+
'; cursor: default;');
|
|
156
|
+
}
|
|
157
|
+
updateVideoStreamSize() {
|
|
158
|
+
if (!this.config.isFlagEnabled(Config_1.Flags.MatchViewportResolution)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const now = new Date().getTime();
|
|
162
|
+
if (now - this.lastTimeResized > 300) {
|
|
163
|
+
const videoElementParent = this.getVideoParentElement();
|
|
164
|
+
if (!videoElementParent) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.onMatchViewportResolutionCallback(videoElementParent.clientWidth, videoElementParent.clientHeight);
|
|
168
|
+
this.lastTimeResized = new Date().getTime();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
lib_pixelstreamingcommon_ue5_5_1.Logger.Info('Resizing too often - skipping');
|
|
172
|
+
clearTimeout(this.resizeTimeoutHandle);
|
|
173
|
+
this.resizeTimeoutHandle = window.setTimeout(() => this.updateVideoStreamSize(), 100);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.VideoPlayer = VideoPlayer;
|
|
178
178
|
//# sourceMappingURL=VideoPlayer.js.map
|