Skip to content

Commit 68c8e52

Browse files
authored
Merge pull request #256 from BuildFire/feat/migrate-to-video-js
enable adding videos to global playlist
2 parents 74a0104 + 4b080a7 commit 68c8e52

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

widget/controllers/widget.home.controller.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
$rootScope.addAllToPlaylistLoading = false;
621621
if (!$scope.$$phase) $scope.$apply();
622622
} else {
623-
var filteredItems = WidgetHome.items.filter(el => !$rootScope.isInGlobalPlaylist(el.id)).filter(item => item.data.audioUrl);
623+
var filteredItems = WidgetHome.items.filter(el => !$rootScope.isInGlobalPlaylist(el.id)).filter(item => (item.data.audioUrl || item.data.videoUrl));
624624
var itemsToAdd = [...filteredItems].splice(0, freeSlots);
625625
GlobalPlaylist.insertAndUpdateAll(itemsToAdd).then(() => {
626626
for (let item of itemsToAdd) {
@@ -1118,27 +1118,21 @@
11181118
});
11191119
};
11201120

1121-
if ($rootScope.globalPlaylist && $rootScope.online) {
1121+
if ($rootScope.online) {
11221122
getCurrentUser(() => {
11231123
getGlobalPlaylistLimit();
11241124

11251125
getGlobalPlaylistItems()
11261126
.then(getRecords)
11271127
.finally(() => {
1128-
$rootScope.loadingGlobalPlaylist = false;
1128+
setTimeout(() => {
1129+
WidgetHome.isBusy = false;
1130+
$rootScope.loadingData = false;
1131+
$rootScope.loadingGlobalPlaylist = false;
1132+
if (!$scope.$$phase) $scope.$apply();
1133+
}, 0);
11291134
});
11301135
});
1131-
} else if ($rootScope.online) {
1132-
getGlobalPlaylistItems()
1133-
.then(getRecords)
1134-
.finally(() => {
1135-
setTimeout(() => {
1136-
WidgetHome.isBusy = false;
1137-
$rootScope.loadingData = false;
1138-
$rootScope.loadingGlobalPlaylist = false;
1139-
if (!$scope.$$phase) $scope.$apply();
1140-
}, 0);
1141-
});
11421136
} else {
11431137
getCachedItems((err, res) => {});
11441138
}
@@ -1246,7 +1240,7 @@
12461240
listItems.push({ id: "openLinks", text: getString("homeDrawer.openLinks") });
12471241
}
12481242

1249-
if (WidgetHome.media.data.content.globalPlaylist && $rootScope.online && item.data.audioUrl) {
1243+
if (WidgetHome.media.data.content.globalPlaylist && $rootScope.online && (item.data.audioUrl || item.data.videoUrl)) {
12501244
if ($rootScope.isInGlobalPlaylist(item.id)) {
12511245
listItems.push({ id: "removeFromPlaylist", text: getString("homeDrawer.removeFromPlaylist") });
12521246
}

widget/controllers/widget.media.controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
listItems.push({ id: "openLinks", text: getString("itemDrawer.openLinks") });
143143
}
144144

145-
if (WidgetMedia.media.data.content.globalPlaylist && $rootScope.online && WidgetMedia.item.data.audioUrl) {
145+
if (WidgetMedia.media.data.content.globalPlaylist && $rootScope.online && (WidgetMedia.item.data.audioUrl || WidgetMedia.item.data.videoUrl)) {
146146
if ($rootScope.isInGlobalPlaylist(WidgetMedia.item.id)) {
147147
listItems.push({ id: "removeFromPlaylist", text: getString("itemDrawer.removeFromPlaylist") });
148148
}
@@ -689,6 +689,8 @@
689689
Location.goToHome();
690690
} else if (event.name === EVENTS.DESIGN_LAYOUT_CHANGE) {
691691
WidgetMedia.media.data.design = event.message.design
692+
} else if (event.name === EVENTS.SETTINGS_CHANGE) {
693+
WidgetMedia.media.data.content = event.message.itemUpdatedData;
692694
}
693695

694696
if ($rootScope.autoPlay || $rootScope.skipMediaPage) {

widget/services.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@
614614
controls: true,
615615
techOrder: ["html5", "youtube", "vimeo"],
616616
enableDocumentPictureInPicture: true,
617-
autoplay: $rootScope.autoPlay
618617
});
619618

620619
addNextPreviousButtons();
@@ -625,13 +624,6 @@
625624
type: videoType,
626625
});
627626

628-
// this interval is to handle youtube videos autoplay
629-
if ($rootScope.autoPlay) {
630-
playInterval = setInterval(() => {
631-
play();
632-
}, 500)
633-
}
634-
635627
// to handle click on mobile
636628
vidPlayer.controlBar.playToggle.on("touchend", function () {
637629
if (vidPlayer.paused()) {
@@ -701,9 +693,23 @@
701693
if (type === 'video/mp4') {
702694
vidPlayer.on('loadedmetadata', function () {
703695
callback();
696+
697+
if ($rootScope.autoPlay) {
698+
playInterval = setInterval(() => {
699+
play();
700+
}, 500);
701+
}
704702
});
705703
} else {
706-
callback();
704+
vidPlayer.tech().on("ready", function () {
705+
if ($rootScope.autoPlay) {
706+
playInterval = setInterval(() => {
707+
play();
708+
}, 500);
709+
}
710+
711+
callback();
712+
});
707713
}
708714
}
709715

0 commit comments

Comments
 (0)