PageSourceSearch

https://1spotmedia.com/assets/theme/rjr/js/directives/dai-player.js?v=3.31

js 1spotmedia.com collected 2026-09-24 12:45:35 UTC 10,298 bytes, 260 lines download raw bytes

1rjrApp.directive('daiPlayer', function() {
2    return {
3        restrict: 'E',
4        transclude: true,
5        scope: {
6            video: '=video',
7            id: '@id'
8        },
9        controller: ['$scope', '$rootScope', '$log', '$filter', function jwpCtrl($scope, $rootScope, $log, $filter) {
10
11            var httpsFilt = $filter('https')
12            $scope.getPosterUrl = function(vid) {
13                var livePoster = '';
14                if(vid.mediaType == "channel"){
15                    if (vid.ChannelLogoLarge) {
16                        livePoster = vid.ChannelLogoLarge.downloadUrl || vid.ChannelLogoLarge.streamingUrl;
17                    }
18                } else if (vid.PosterH) {
19                    livePoster = vid.PosterH.downloadUrl || vid.PosterH.streamingUrl;
20                }
21                return livePoster;
22            };
23
24            $scope.handleMediaEvents = function(action, videoName) {
25                gtag('event', 'video', {
26                    'video_action': action,
27                    'video_title': videoName
28                });
29                //ga('send', { hitType: 'event', eventCategory: 'Videos', eventAction: action, eventLabel: videoName });
30            };
31
32            // Backup Stream used in tests
33            var BACKUP_STREAM ='http://storage.googleapis.com/testtopbox-public/video_content/bbb/' +'master.m3u8';
34            
35            var vid = $scope.video;
36           // Setting Video URL
37        
38           if (vid !== undefined) {
39            if (vid.HLSBlockedStream) {
40                var videoUrl = vid.HLSBlockedStream.url || vid.HLSBlockedStream.downloadUrl;
41                if (videoUrl.indexOf("?") < 0)
42                    videoUrl += "?";
43                var posterUrl = $scope.getPosterUrl(vid);
44                if(vid.HLSBlockedStream.daiAssetId){
45                    var daiAssetId = vid.HLSBlockedStream.daiAssetId;
46                }
47            }
48            if (vid.HLSStream) {
49                var videoUrl = vid.HLSStream.url || vid.HLSStream.downloadUrl;
50                if (videoUrl.indexOf("?") < 0)
51                    videoUrl += "?";
52                var posterUrl = $scope.getPosterUrl(vid);
53            }
54            if (vid.Video) {
55                var videoUrl = vid.Video.url || vid.Video.downloadUrl;
56                if (videoUrl.indexOf("?") < 0)
57                    videoUrl += "?";
58                var posterUrl = $scope.getPosterUrl(vid);
59            }
60            if (vid.Trailer) {
61                var videoUrl = vid.Trailer.url || vid.Trailer.downloadUrl;
62                $scope.trailer = true;
63                if (videoUrl.indexOf("?") < 0)
64                    videoUrl += "?";
65            }
66            if (vid.mainTrailer) {
67                var videoUrl = vid.mainTrailer.url || vid.mainTrailer.downloadUrl;
68                $scope.trailer = true;
69                if (videoUrl.indexOf("?") < 0)
70                    videoUrl += "?";
71            }
72
73            if (vid.content) {
74                angular.forEach(vid.content, function(value, key) {
75                    if (value.assetTypes[0] == "HLS Stream" || value.assetTypes[0] == "HLS Blocked Stream" || value.assetTypes[0] == "Video") {
76                        var videoUrl = value.url || value.downloadUrl;
77                        if (videoUrl.indexOf("?") < 0)
78                            videoUrl += "?";
79                    }
80                });
81            }
82            if (vid.catchUpUrl) {
83                var videoUrl = vid.catchUpUrl;
84                if (videoUrl.indexOf("?") < 0)
85                    videoUrl += "?";
86            }
87            
88            var channelId = '';
89            var publisherId = '';
90            if (vid.adPolicyId) {
91                channelId = vid.adPolicyId;
92                publisherId = "5acb749228a061637874caa2";
93            }
94          }
95          
96              var src = {
97                hls: videoUrl
98              };
99              // Player settings
100              var settings = {
101                licenseKey: 'bGhieHhxdmllY0AxNTkwMzE2',
102                src: src,
103                pip: true,
104                autoHeightMode: true,
105                 // Since Chrome 66+, Firefox 66+ and Safari 11+ autoplay with sound is blocked by default on page load
106                // We thus recommend using a unified muted autoplay approach that works well on both desktop and mobile
107                muted: false,
108                ads: daiAssetId? true : false,
109                // enables IMA DAI support in Radiant Media Player
110                adImaDai: daiAssetId? true : false,
111                // DAI Live stream asset key
112                adImaDaiLiveAssetKey: daiAssetId? daiAssetId : "" ,
113                // Backup HLS stream in case the DAI stream is not available when requested
114                // Note that this is also the HLS stream that will be used on iOS since hls.js does not work on iOS
115                adImaDaiBackupStream: src.hls,
116                // In macOS and iPadOS Safari we force hls.js usage to enable IMA DAI support
117                forceHlsJSOnMacOSIpadOSSafari: true,
118                // ad label that can be displayed within player UI when an ad is on stage
119                labels: {
120                  ads: {
121                    controlBarCustomMessage: 'Ads'
122                  }
123                },
124                poster: posterUrl? posterUrl : [],
125                 // Logo settings
126                logo: vid.ChannelLogoRadio ? vid.ChannelLogoRadio.downloadUrl + "?" : '/assets/theme/rjr/images/logo.png?',
127                logoPosition: 'topleft',
128                logoWatermark: true,
129                logoPosition : 'bottomright',
130              };
131
132            
133
134              if(vid.ChannelLogoRadio){
135                  
136                  let rmpPlayer = document.getElementById('rmpPlayer');
137                  rmpPlayer.classList.add('rmp-player-middle');
138
139                  let rmpPlayerContainer = document.getElementById('detach-container');
140                  
141                  rmpPlayerContainer.classList.add('rmp-player-middle-container');
142          
143                  settings.logoPosition = 'topright';
144              }
145              
146
147        
148              var elementID = 'rmpPlayer';
149              var container = document.getElementById(elementID);
150
151              var attachContainer = document.getElementById('attach-container');
152              var detachContainer = document.getElementById('detach-container');
153
154              var rmp = new RadiantMP(elementID);
155
156
157
158              var rmpFW = rmp.getFramework();
159              var debug = false;
160              var _log = function(data) {
161              if (window.console && window.console.log && data) {
162                  window.console.log(data);
163              }
164              };
165              var playerAttached = true;
166              var viewablePreviousRatio = 0.5;
167              var firstView = false;
168          
169              // function to run when the player should detach
170              var _detachPlayer = function () {
171              playerAttached = false;
172              rmpFW.addClass(detachContainer, 'rmp-detach');
173              rmp.resize();
174              };
175          
176              // function to run when the player should be attached to its original location
177              var _attachPlayer = function () {
178              playerAttached = true;
179              rmpFW.removeClass(detachContainer, 'rmp-detach');
180              rmp.resize();
181              };
182          
183              var _handleIntersect = function (entries) {
184              entries.forEach(function (entry) {
185                  if (entry.intersectionRatio > viewablePreviousRatio) {
186                  if (debug) {
187                      _log('player comes into view');
188                  }
189                  // we do not want to detach player before viewer has scrolled to it at least once
190                  if (!firstView) {
191                      firstView = true;
192                      // if we wanted to start playback automatically when player comes into view the first time
193                      // we would call play()
194                      // in such case we should use muted: true in player settings as well
195                      // rmp.play();
196                  }
197                  if (!playerAttached) {
198                      _attachPlayer();
199                  }
200                  } else {
201                  if (debug) {
202                      _log('player comes out of view');
203                  }
204                  if (playerAttached && firstView) {
205                      _detachPlayer();
206                  }
207                  }
208                  viewablePreviousRatio = entry.intersectionRatio;
209              });
210              };
211          
212              var _attachViewableObserver = function () {
213              container.removeEventListener('ready', _attachViewableObserver);
214              if (typeof window.IntersectionObserver !== 'undefined') {
215                  var options = {
216                  root: null,
217                  rootMargin: '0px',
218                  threshold: [0.5],
219                  };
220                  var viewableObserver = new IntersectionObserver(_handleIntersect, options);
221                  viewableObserver.observe(attachContainer);
222              }
223              };
224          
225              // when player is ready create IntersectionObserver
226              container.addEventListener('ready', _attachViewableObserver);
227
228
229
230
231              rmp.init(settings);
232
233
234    
235              
236              // Event Play Google Analytics
237              container.addEventListener('ready', function() {
238
239
240                  $scope.handleMediaEvents('Play', vid.title);
241                });                
242               
243  
244              container.addEventListener('error', function() {
245                  $scope.handleMediaEvents('Error', vid.title);
246              });
247
248              container.addEventListener('ended', function() {
249                  $scope.handleMediaEvents('Ended', vid.title);
250              });
251           
252        }],
253        link: function(scope, element, attrs) {
254            scope.$watch("video", function(newValue, oldValue) {
255                //scope.setupVideo(newValue);
256            }, true);
257        },
258        templateUrl: '/assets/theme/rjr/html/directives/dai-player.html'
259    };
260})

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.