mediaViewerComponent.js
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import './mediaDataService';
import '../vendor/jquery.scrollTo-min';
angular.module('footyroom').component('frMediaViewer', {
templateUrl: 'media-viewer-template',
bindings: {
r16x9: '<',
},
controller: ['mediaEmbedder', 'mediaData', function (mediaEmbedder, mediaData) {
var ctrl = this;
var roll;
ctrl.$onInit = $onInit;
function $onInit() {
mediaData.onSelect(function (selectedMedia, scroll) {
showMedia(selectedMedia, scroll);
});
ctrl.selectedMedia = mediaData.getSelected();
if (ctrl.selectedMedia) {
showMedia(ctrl.selectedMedia);
}
}
function showMedia(media, scroll) {
ctrl.selectedMedia = media;
mediaEmbedder.embed(media, '#video');
// Destroy roll if already exists.
if (roll) {
roll.destroy();
}
// Add preroll ad.
if ($('#video iframe').length && window.RollerInlineTag) {
roll = new RollerInlineTag('#video iframe', 'https://pubads.g.doubleclick.net/gampad/ads?sz=575x400&iu=/1873845/FR_Match_Video&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=' + encodeURIComponent(window.location.href) + '&correlator=[timestamp]');
}
setTimeout(function () {
if (scroll) {
$('body').scrollTo('.videos-wrap', 300);
}
}, 100);
}
}],
});