// Metro module 14167 (f14168). import { Logger } from "../../../_bundle/log"; import { SessionManager } from "../utils/SessionManager"; import Module14165 from "../../../_bundle/Module14165"; let c9943_3 = new Logger("MobileCustomMuxIntegration"); const player_version = "1.0.0"; const video_cdn = "Cloudflare"; let c9943_6 = 1000; export class MobileCustomMuxIntegration { isInitialized = false; viewInitEmitted = false; playerReadyEmitted = false; playStarted = false; playingEmitted = false; currentPlayheadTime = 0; currentRendition = null; getPlayheadTime = () => this.currentPlayheadTime * c9943_6; getStateData = () => this.videoState; constructor(a0) { this.config = a0; this.sessionId = SessionManager.generateSessionId(); this.playerId = `discord-mobile-${this.sessionId}`; this.videoState = { player_is_paused: true, player_width: 0, player_height: 0, player_autoplay_on: false, player_preload_on: true, video_cdn, video_series: a0.contentMetadata.questId, video_producer: a0.contentMetadata.gameId, video_brand: a0.contentMetadata.gameName, video_title: a0.contentMetadata.title, video_stream_type: a0.contentMetadata.videoStreamType, video_source_url: a0.contentMetadata.contentId, video_source_mime_type: a0.contentMetadata.videoStreamType === "hls" ? "application/x-mpegURL" : "video/mp4", video_source_duration: a0.contentMetadata.durationMs }; } initialize() { L7: { const muxEnvKey = this.getMuxEnvKey(); if (muxEnvKey != null && muxEnvKey.length !== 0) { try { const playerId = this.playerId; let debug = this.config.debug; if (debug == null) { debug = false; } Module14165.init(playerId, { debug, getPlayheadTime: this.getPlayheadTime, getStateData: this.getStateData, data: this.mapConfigToMuxData(muxEnvKey) }); this.isInitialized = true; c9943_3.info("Mux Data mobile integration initialized", { playerId: this.playerId }); break L7; } catch ($e) { c9943_3.error("Error initializing Mux mobile integration", $e); this.isInitialized = false; break L7; } } c9943_3.info("Mux environment key not available, skipping QoE tracking"); } } updatePlayheadTime(a0) { this.currentPlayheadTime = a0; } updateVideoDimensions(a0, a1) { this.videoState.player_width = a0; this.videoState.player_height = a1; } updateVideoSourceDimensions(a0, a1) { this.videoState.video_source_width = a0; this.videoState.video_source_height = a1; } updateVideoSource(a0, a1, a2) { this.videoState.video_source_url = a0; this.videoState.video_source_mime_type = a1; this.videoState.video_source_duration = a2 != null ? a2 * c9943_6 : void 0; } updatePlayerState(a0, a1) { this.videoState.player_is_paused = a0; if (a1 != null) { this.videoState.player_is_fullscreen = a1; } } emitPlayerReady() { if (this.isInitialized && !this.playerReadyEmitted) { try { Module14165.emit(this.playerId, "playerready"); this.playerReadyEmitted = true; } catch ($e) { c9943_3.error("Error emitting playerready event", $e); } } } emitViewInit() { if (this.isInitialized && !this.viewInitEmitted) { try { Module14165.emit(this.playerId, "viewinit"); this.viewInitEmitted = true; } catch ($e) { c9943_3.error("Error emitting viewinit event", $e); } } } emitLoadStart() { if (this.isInitialized) { try { this.emitViewInit(); } catch ($e) { c9943_3.error("Error emitting loadstart/viewinit event", $e); } } } emitLoad(a0) { if (this.isInitialized) { try { this.updateVideoSource(void 0, void 0, a0); } catch ($e) { c9943_3.error("Error emitting load events", $e); } } } emitPlay() { if (this.isInitialized) { try { if (!this.viewInitEmitted) { this.emitViewInit(); } this.updatePlayerState(false); Module14165.emit(this.playerId, "play"); this.playStarted = true; this.playingEmitted = false; } catch ($e) { c9943_3.error("Error emitting play event", $e); } } } emitPause() { if (this.isInitialized) { try { this.updatePlayerState(true); Module14165.emit(this.playerId, "pause"); } catch ($e) { c9943_3.error("Error emitting pause event", $e); } } } emitPlaying() { if (this.isInitialized && !this.playingEmitted) { try { if (!this.viewInitEmitted) { this.emitViewInit(); } if (!this.playStarted) { Module14165.emit(this.playerId, "play"); this.playStarted = true; } Module14165.emit(this.playerId, "playing"); this.playingEmitted = true; } catch ($e) { c9943_3.error("Error emitting playing event", $e); } } } emitWaiting() { if (this.isInitialized) { try { Module14165.emit(this.playerId, "waiting"); } catch ($e) { c9943_3.error("Error emitting waiting event", $e); } } } emitCanPlay() { this.emitPlayerReady(); } emitSeeking() { if (this.isInitialized) { try { Module14165.emit(this.playerId, "seeking"); } catch ($e) { c9943_3.error("Error emitting seeking event", $e); } } } emitSeeked() { if (this.isInitialized) { try { Module14165.emit(this.playerId, "seeked"); } catch ($e) { c9943_3.error("Error emitting seeked event", $e); } } } emitEnded() { if (this.isInitialized) { try { Module14165.emit(this.playerId, "ended"); this.emitViewEnd(); } catch ($e) { c9943_3.error("Error emitting ended event", $e); } } } emitError(a0) { if (this.isInitialized) { try { Module14165.emit(this.playerId, "error", a0); } catch ($e) { c9943_3.error("Error emitting error event", $e); } } } emitTimeUpdate() { if (this.isInitialized) { try { if (this.playStarted && !this.playingEmitted) { this.emitPlaying(); } Module14165.emit(this.playerId, "timeupdate", { player_playhead_time: this.currentPlayheadTime * c9943_6 }); } catch ($e) { c9943_3.error("Error emitting timeupdate event", $e); } } } emitRenditionChange(a0, a1, a2) { L8: { if (this.isInitialized) { if (this.currentRendition != null && this.currentRendition.width === a0 && this.currentRendition.height === a1 && this.currentRendition.bitrate === a2) { break L8; } try { this.currentRendition = { width: a0, height: a1, bitrate: a2 }; this.updateVideoSourceDimensions(a0, a1); Module14165.emit(this.playerId, "renditionchange", { video_source_width: a0, video_source_height: a1, video_source_bitrate: a2 }); } catch ($e) { c9943_3.error("Error emitting renditionchange event", $e); } } } } destroy() { if (this.isInitialized) { try { this.emitViewEnd(); Module14165.emit(this.playerId, "destroy"); this.isInitialized = false; c9943_3.info("Mux Data mobile integration destroyed", { playerId: this.playerId }); } catch ($e) { c9943_3.error("Error destroying Mux mobile integration", $e); } } } emitViewEnd() { if (this.isInitialized) { try { Module14165.emit(this.playerId, "viewend"); } catch ($e) { c9943_3.error("Error emitting viewend event", $e); } } } getSessionId() { return this.sessionId; } hasPlayStarted() { return this.playStarted; } mapConfigToMuxData(a0) { let gameName = this.config.contentMetadata.gameName; if (gameName == null) { gameName = "Discord"; } return { env_key: a0, session_id: this.sessionId, player_name: "discord-mobile", player_version, 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: player_version, 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: gameName, video_cdn, video_stream_type: this.config.contentMetadata.videoStreamType, view_client_application_name: this.getBuildChannel(), view_client_application_version: this.getAppVersion(), experiment_name: this.config.contentMetadata.experimentName }; } getAppVersion() { let appVersion = this.config.appVersion; if (appVersion == null) { appVersion = "unknown"; } return appVersion; } getMuxEnvKey() { return "1qd16mdmdjasipqg3irobln4u"; } getBuildChannel() { let releaseChannel = this.config.releaseChannel; if (releaseChannel == null) { releaseChannel = "stable"; } return releaseChannel; } }