Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
337 lines
11 KiB
TypeScript
337 lines
11 KiB
TypeScript
// Module ID: 15223
|
|
// Function ID: 15224
|
|
// Name: MobileCustomMuxIntegration
|
|
// Dependencies: [4, 15219, 15221, 2]
|
|
|
|
// Module 15223 (MobileCustomMuxIntegration)
|
|
import logger_Logger from "logger/Logger" /* 4 */;
|
|
import UDefault from "U" /* 15221 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const logger = new logger_Logger.Logger("MobileCustomMuxIntegration");
|
|
let c4 = "1.0.0";
|
|
const Cloudflare = "Cloudflare";
|
|
let c6 = 1000;
|
|
let result = size.fileFinishedImporting("modules/video-qoe/integrations/MobileCustomMuxIntegration.tsx");
|
|
class MobileCustomMuxIntegration {
|
|
constructor(arg0) {
|
|
obj1 = Object.create(new.target.prototype);
|
|
closure_0 = obj1;
|
|
obj1.isInitialized = false;
|
|
obj1.viewInitEmitted = false;
|
|
obj1.playerReadyEmitted = false;
|
|
obj1.playStarted = false;
|
|
obj1.playingEmitted = false;
|
|
obj1.currentPlayheadTime = 0;
|
|
obj1.currentRendition = null;
|
|
obj1.getPlayheadTime = function getPlayheadTime() {
|
|
return obj2.currentPlayheadTime * c6;
|
|
};
|
|
obj1.getStateData = function getStateData() {
|
|
return obj2.videoState;
|
|
};
|
|
obj1.config = global;
|
|
SessionManager = closure_0(closure_2[1]).SessionManager;
|
|
obj1.sessionId = SessionManager.generateSessionId();
|
|
obj1.playerId = "discord-mobile-" + obj1.sessionId;
|
|
obj = { player_is_paused: true, player_width: 0, player_height: 0, player_autoplay_on: false, player_preload_on: true, video_cdn: Cloudflare, video_series: global.contentMetadata.questId, video_producer: global.contentMetadata.gameId, video_brand: global.contentMetadata.gameName, video_title: global.contentMetadata.title, video_stream_type: global.contentMetadata.videoStreamType, video_source_url: global.contentMetadata.contentId, video_source_mime_type: null, video_source_duration: null };
|
|
str = "video/mp4";
|
|
if ("hls" === global.contentMetadata.videoStreamType) {
|
|
str = "application/x-mpegURL";
|
|
}
|
|
obj.video_source_mime_type = str;
|
|
obj.video_source_duration = global.contentMetadata.durationMs;
|
|
obj1.videoState = obj;
|
|
return obj1;
|
|
}
|
|
}
|
|
const prototype = MobileCustomMuxIntegration.prototype;
|
|
prototype["initialize"] = function initialize() {
|
|
const self = this;
|
|
const muxEnvKey = this.getMuxEnvKey();
|
|
if (null != muxEnvKey) {
|
|
if (0 !== muxEnvKey.length) {
|
|
try {
|
|
let flag = self.config.debug;
|
|
if (flag == null) {
|
|
flag = false;
|
|
}
|
|
const obj3 = { debug: flag, getPlayheadTime: null, getStateData: null, data: null };
|
|
({ getPlayheadTime: obj2.getPlayheadTime, getStateData: obj2.getStateData } = self);
|
|
obj3.data = self.mapConfigToMuxData(muxEnvKey);
|
|
UDefault.init(self.playerId, obj3);
|
|
self.isInitialized = true;
|
|
const obj5 = { playerId: self.playerId };
|
|
logger.info("Mux Data mobile integration initialized", obj5);
|
|
} catch (tmp8) {
|
|
logger.error("Error initializing Mux mobile integration", tmp8);
|
|
tmp.isInitialized = false;
|
|
}
|
|
}
|
|
}
|
|
logger.info("Mux environment key not available, skipping QoE tracking");
|
|
};
|
|
prototype["updatePlayheadTime"] = function updatePlayheadTime(currentPlayheadTime) {
|
|
this.currentPlayheadTime = currentPlayheadTime;
|
|
};
|
|
prototype["updateVideoDimensions"] = function updateVideoDimensions(player_width, player_height) {
|
|
this.videoState.player_width = player_width;
|
|
this.videoState.player_height = player_height;
|
|
};
|
|
prototype["updateVideoSourceDimensions"] = function updateVideoSourceDimensions(video_source_width, video_source_height) {
|
|
this.videoState.video_source_width = video_source_width;
|
|
this.videoState.video_source_height = video_source_height;
|
|
};
|
|
prototype["updateVideoSource"] = function updateVideoSource(video_source_url, video_source_mime_type, arg2) {
|
|
this.videoState.video_source_url = video_source_url;
|
|
this.videoState.video_source_mime_type = video_source_mime_type;
|
|
let result;
|
|
if (null != arg2) {
|
|
result = arg2 * c6;
|
|
}
|
|
this.videoState.video_source_duration = result;
|
|
};
|
|
prototype["updatePlayerState"] = function updatePlayerState(player_is_paused, player_is_fullscreen) {
|
|
this.videoState.player_is_paused = player_is_paused;
|
|
if (null != player_is_fullscreen) {
|
|
this.videoState.player_is_fullscreen = player_is_fullscreen;
|
|
}
|
|
};
|
|
prototype["emitPlayerReady"] = function emitPlayerReady() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
if (!self.playerReadyEmitted) {
|
|
try {
|
|
UDefault.emit(self.playerId, "playerready");
|
|
self.playerReadyEmitted = true;
|
|
} catch (tmp4) {
|
|
logger.error("Error emitting playerready event", tmp4);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
prototype["emitViewInit"] = function emitViewInit() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
if (!self.viewInitEmitted) {
|
|
try {
|
|
UDefault.emit(self.playerId, "viewinit");
|
|
self.viewInitEmitted = true;
|
|
} catch (tmp4) {
|
|
logger.error("Error emitting viewinit event", tmp4);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
prototype["emitLoadStart"] = function emitLoadStart() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
self.emitViewInit();
|
|
} catch (tmp2) {
|
|
logger.error("Error emitting loadstart/viewinit event", tmp2);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitLoad"] = function emitLoad(arg0) {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
self.updateVideoSource(undefined, undefined, arg0);
|
|
} catch (tmp3) {
|
|
logger.error("Error emitting load events", tmp3);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitPlay"] = function emitPlay() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
if (!self.viewInitEmitted) {
|
|
self.emitViewInit();
|
|
}
|
|
self.updatePlayerState(false);
|
|
UDefault.emit(self.playerId, "play");
|
|
self.playStarted = true;
|
|
self.playingEmitted = false;
|
|
} catch (tmp6) {
|
|
logger.error("Error emitting play event", tmp6);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitPause"] = function emitPause() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
self.updatePlayerState(true);
|
|
UDefault.emit(self.playerId, "pause");
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting pause event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitPlaying"] = function emitPlaying() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
if (!self.playingEmitted) {
|
|
try {
|
|
if (!self.viewInitEmitted) {
|
|
self.emitViewInit();
|
|
}
|
|
if (!self.playStarted) {
|
|
UDefault.emit(self.playerId, "play");
|
|
self.playStarted = true;
|
|
}
|
|
UDefault.emit(self.playerId, "playing");
|
|
self.playingEmitted = true;
|
|
} catch (tmp8) {
|
|
logger.error("Error emitting playing event", tmp8);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
prototype["emitWaiting"] = function emitWaiting() {
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(tmp.playerId, "waiting");
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting waiting event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitCanPlay"] = function emitCanPlay() {
|
|
this.emitPlayerReady();
|
|
};
|
|
prototype["emitSeeking"] = function emitSeeking() {
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(tmp.playerId, "seeking");
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting seeking event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitSeeked"] = function emitSeeked() {
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(tmp.playerId, "seeked");
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting seeked event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitEnded"] = function emitEnded() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(self.playerId, "ended");
|
|
self.emitViewEnd();
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting ended event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitError"] = function emitError(arg0) {
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(tmp.playerId, "error", arg0);
|
|
} catch (tmp6) {
|
|
logger.error("Error emitting error event", tmp6);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitTimeUpdate"] = function emitTimeUpdate() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
let playStarted = self.playStarted;
|
|
if (playStarted) {
|
|
playStarted = !self.playingEmitted;
|
|
}
|
|
if (playStarted) {
|
|
self.emitPlaying();
|
|
}
|
|
const obj2 = { player_playhead_time: self.currentPlayheadTime * c6 };
|
|
UDefault.emit(self.playerId, "timeupdate", obj2);
|
|
} catch (tmp6) {
|
|
logger.error("Error emitting timeupdate event", tmp6);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitRenditionChange"] = function emitRenditionChange(width, height, bitrate) {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
const size = { width, height, bitrate };
|
|
self.currentRendition = size;
|
|
const result = self.updateVideoSourceDimensions(width, height);
|
|
const obj = { video_source_width: width, video_source_height: height, video_source_bitrate: bitrate };
|
|
UDefault.emit(self.playerId, "renditionchange", obj);
|
|
} catch (tmp9) {
|
|
logger.error("Error emitting renditionchange event", tmp9);
|
|
}
|
|
}
|
|
};
|
|
prototype["destroy"] = function destroy() {
|
|
const self = this;
|
|
if (this.isInitialized) {
|
|
try {
|
|
self.emitViewEnd();
|
|
UDefault.emit(self.playerId, "destroy");
|
|
self.isInitialized = false;
|
|
const obj2 = { playerId: self.playerId };
|
|
logger.info("Mux Data mobile integration destroyed", obj2);
|
|
} catch (tmp7) {
|
|
logger.error("Error destroying Mux mobile integration", tmp7);
|
|
}
|
|
}
|
|
};
|
|
prototype["emitViewEnd"] = function emitViewEnd() {
|
|
if (this.isInitialized) {
|
|
try {
|
|
UDefault.emit(tmp.playerId, "viewend");
|
|
} catch (tmp5) {
|
|
logger.error("Error emitting viewend event", tmp5);
|
|
}
|
|
}
|
|
};
|
|
prototype["getSessionId"] = function getSessionId() {
|
|
return this.sessionId;
|
|
};
|
|
prototype["hasPlayStarted"] = function hasPlayStarted() {
|
|
return this.playStarted;
|
|
};
|
|
prototype["mapConfigToMuxData"] = function mapConfigToMuxData(muxEnvKey) {
|
|
const self = this;
|
|
const obj = { env_key: muxEnvKey, session_id: this.sessionId, player_name: "discord-mobile", player_version: v100, player_software_name: "react-native-video", player_software_version: "5.2.1-discord", player_mux_plugin_name: "discord-mobile-custom-integration", player_mux_plugin_version: v100, video_id: this.config.contentMetadata.contentId, video_title: this.config.contentMetadata.title, video_duration: this.config.contentMetadata.durationMs, video_content_type: this.config.contentMetadata.contentType, video_series: this.config.contentMetadata.questId, video_producer: this.config.contentMetadata.gameId, video_brand: null, video_cdn: null, video_stream_type: null, view_client_application_name: null, view_client_application_version: null, experiment_name: null };
|
|
let str = this.config.contentMetadata.gameName;
|
|
if (str == null) {
|
|
str = "Discord";
|
|
}
|
|
obj.video_brand = str;
|
|
obj.video_cdn = Cloudflare;
|
|
obj.video_stream_type = self.config.contentMetadata.videoStreamType;
|
|
obj.view_client_application_name = self.getBuildChannel();
|
|
obj.view_client_application_version = self.getAppVersion();
|
|
obj.experiment_name = self.config.contentMetadata.experimentName;
|
|
return obj;
|
|
};
|
|
prototype["getAppVersion"] = function getAppVersion() {
|
|
let str = this.config.appVersion;
|
|
if (str == null) {
|
|
str = "unknown";
|
|
}
|
|
return str;
|
|
};
|
|
prototype["getMuxEnvKey"] = function getMuxEnvKey() {
|
|
return "1qd16mdmdjasipqg3irobln4u";
|
|
};
|
|
prototype["getBuildChannel"] = function getBuildChannel() {
|
|
let str = this.config.releaseChannel;
|
|
if (str == null) {
|
|
str = "stable";
|
|
}
|
|
return str;
|
|
};
|
|
|
|
export { MobileCustomMuxIntegration };
|