PageSourceSearch

https://www.cbnrecife.com/wp-content/plugins/webtonative/qtmedia-n…qtmedia-native-control.js?ver=1.1.0&ver=1.2

js cbnrecife.com collected 2026-10-02 11:25:14 UTC 3,108 bytes, 99 lines download raw bytes

1(function () {
2  // Ensure WTN.MediaPlayer exists
3  if (typeof window.WTN === 'undefined' || typeof window.WTN.MediaPlayer === 'undefined') {
4    console.error('WTN MediaPlayer is not available.');
5    return;
6  }
7
8  // Check QTMediaSettings for enabled monitoring
9  const audioMonitoringEnabled = QTMediaSettings.audioMonitoring === 'yes';
10  const videoMonitoringEnabled = QTMediaSettings.videoMonitoring === 'yes';
11
12  // Initialize global active media element tracker
13  window.activeMediaElement = null;
14
15  // Native media control functions
16  function playMedia(url, image) {
17    window.WTN.MediaPlayer.playMedia({ url, imageUrl: image });
18  }
19
20  function pauseMedia() {
21    window.WTN.MediaPlayer.pauseMedia();
22  }
23
24  function stopMedia() {
25    window.WTN.MediaPlayer.stopMedia();
26  }
27
28  // Function to bind media controls to <audio> and <video> elements
29  function bindMediaElement(mediaElement) {
30    mediaElement.addEventListener('play', () => {
31      if (window.activeMediaElement && window.activeMediaElement !== mediaElement) {
32        window.activeMediaElement.pause();
33      }
34      window.activeMediaElement = mediaElement;
35      const mediaUrl = mediaElement.currentSrc;
36      const mediaImage = mediaElement.getAttribute('data-thumbnail') || '';
37      playMedia(mediaUrl, mediaImage);
38    });
39
40    mediaElement.addEventListener('pause', () => {
41      if (window.activeMediaElement === mediaElement) {
42        pauseMedia();
43      }
44    });
45
46    mediaElement.addEventListener('ended', () => {
47      if (window.activeMediaElement === mediaElement) {
48        stopMedia();
49        window.activeMediaElement = null;
50      }
51    });
52  }
53
54  // Initialize media controls for <audio> and <video> elements
55  function initializeMediaControls() {
56    if (audioMonitoringEnabled) {
57      const audioElements = document.querySelectorAll('audio');
58      audioElements.forEach((audioElement) => bindMediaElement(audioElement));
59    }
60
61    if (videoMonitoringEnabled) {
62      const videoElements = document.querySelectorAll('video');
63      videoElements.forEach((videoElement) => bindMediaElement(videoElement));
64    }
65  }
66
67  // Monitor for dynamically added media elements
68  function monitorDynamicMedia() {
69    const container = document.body;
70    const observer = new MutationObserver((mutations) => {
71      mutations.forEach((mutation) => {
72        mutation.addedNodes.forEach((node) => {
73          if (node.tagName === 'AUDIO' && audioMonitoringEnabled) {
74            console.log('New audio element detected:', node);
75            bindMediaElement(node);
76          }
77
78          if (node.tagName === 'VIDEO' && videoMonitoringEnabled) {
79            console.log('New video element detected:', node);
80            bindMediaElement(node);
81          }
82        });
83      });
84    });
85
86    observer.observe(container, {
87      childList: true,
88      subtree: true,
89    });
90
91    console.log('Dynamic media monitoring initialized.');
92  }
93
94  // Initialize functionality when DOM is fully loaded
95  document.addEventListener('DOMContentLoaded', () => {
96    initializeMediaControls();
97    monitorDynamicMedia();
98  });
99})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.