You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently facing multiple caption-related issues within my AngularJS project, specifically with a custom video player directive that utilizes the Plyr library for embedding and controlling Vimeo videos. The main problems revolve around incorrect captioning behavior.
base.directive('plyrPlayer', ['logService', '$timeout', function (logService, $timeout) {
return {
link: function ($scope, $element, $attr) {
var player;
var element = $element[0];
var secondsWatched = $attr.secondsWatched;
var showMaximized = $attr.showMaximized === "on";
var provider = $attr.plyrProvider;
function createPlayer(vimeoId, videotype) {
debugger;
element.setAttribute('data-plyr-provider', videotype);
element.setAttribute('data-plyr-embed-id', vimeoId);
player = new Plyr(element, { "id": "player", "autoplay": false, "hideControls": false, "clickToPlay": false });
player.on("play", function (data) {
var loadingId = $element.data("loadingId");
if (angular.isNumber(loadingId)) {
logService.debug("evimeoPlayer: video loading failed assuming vimeoId: %o", loadingId);
$element.removeData("loadingId");
$element.data("vimeoId", loadingId);
} else
logService.debug("evimeoPlayer: play video vimeoId: %o", $element.data("vimeoId"));
function maximizePlayer(el) {
var style = el.style;
style.position = "fixed";
style.zIndex = "100";
style.top = "0";
style.bottom = "0";
style.left = "0";
style.right = "0";
var iframe = element.firstChild;
style = iframe.style;
// size to 100% of the viewport
style.width = "100vw";
style.height = "100vh";
}
if (angular.isFunction($scope.$parent.onPlayStart))
$scope.$parent.onPlayStart();
if (showMaximized)
maximizePlayer(element);
});
player.on("pause", function (data) {
const instance = data.detail.plyr;
var mydata = {
duration: instance.media.duration,
percent: Math.floor(instance.media.currentTime / instance.media.duration * 100),
seconds: instance.media.currentTime,
vimeoId: $element.data("vimeoId")
};
$scope.$parent[secondsWatched] = mydata;
if (angular.isFunction($scope.$parent.onPlayStop)) {
// $scope.$parent.onPlayStop(data.duration === data.seconds);
$scope.$parent.onPlayStop(false);
}
});
player.on("timeupdate", function (data) {
$timeout(function () {
const instance = data.detail.plyr;
var mydata = {
duration: instance.media.duration,
percent: Math.floor(instance.media.currentTime / instance.media.duration * 100),
seconds: instance.media.currentTime,
vimeoId: $element.data("vimeoId")
};
$scope.$parent[secondsWatched] = mydata;
$scope.$parent.$digest();
$scope[secondsWatched] = mydata;
if (angular.isFunction($scope.$parent.updateSecondsWatched))
$scope.$parent.updateSecondsWatched(mydata);
}, 10);
});
player.on("ended", function (data) {
function minimizePlayer(el) {
var style = el.style;
// return the player to the original size
style.position = "";
style.zIndex = "";
style.top = "";
style.bottom = "";
style.left = "";
style.right = "";
var iframe = el.firstChild;
style = iframe.style;
style.width = "";
style.height = "";
}
logService.debug("evimeoPlayer: video ended vimeoId: %o", $element.data("vimeoId"));
$scope.$parent.onPlayStop(true);
if (showMaximized)
minimizePlayer(element);
});
player.on("loadstart", function (data) {
$element.removeData("loadingId");
$element.data("vimeoId", data.id);
logService.debug("evimeoPlayer: video loaded vimeoId: %o", data.id);
});
player.on("ready", function (data) {
const instance = data.detail.plyr;
var progress = 0;
if (angular.isFunction($scope.$parent.getCurrentProgress))
progress = $scope.$parent.getCurrentProgress();
if (progress <= 0) {
return;
}
data.detail.plyr.loop = false;
//player.embed.setCurrentTime(progress);
player.pause();
});
return player;
}
;
$scope.$watchGroup([$attr.plyrEmbedId, $attr.plyrProvider], function (value1, value2, scope) {
var videotype = scope.$$watchers[0].last;
if (videotype == "vimeo") {
var vimeoId = parseInt(scope.$$watchers[1].last);
if (!angular.isNumber(vimeoId)) {
logService.debug("evimeoPlayer: vimeoId is not available")
return;
}
} else {
var vimeoId = scope.$$watchers[1].last;
}
if (!player) {
debugger;
player = createPlayer(vimeoId, videotype);
logService.debug("evimeoPlayer: created player vimeoId: %o", vimeoId);
$element.data("vimeoId", vimeoId);
} else {
player.pause();
//.then(function () {
// loading the video often doesn't complete to the point that the loaded event is fired
// but the video is loaded. Loading the thumbnail image fails. Capture the loadingId and
// apply that in playing if it exists.
$element.data("loadingId", vimeoId);
logService.debug("evimeoPlayer: video loading vimeoId: %o", vimeoId);
player.source = {
type: 'video',
sources: [
{
src: vimeoId,
provider: videotype,
},
],
};
console.log(player);
$element.data("vimeoId", vimeoId);
}
}, true);
},
restrict: 'EA',
scope: false
}
Got the same issue. And while looking for a misconfiguration on my part, I stumbled upon the example code here, where it also has the same issue. https://codepen.io/pen?template=bKeXNq
The captions of the embedded vimeo video are getting displayed and if CC is active or getting activated they will be displayed additionally. It seems that captions are enabled by default before the video is implemented for the plyr player itself.
If there is a configuration which I missed, please let me know. Any help would be appreciated.
Kind regards
EDIT:
I just played a bit around. When I switch to a language that is not available for captions, they won't show. If I then click on CC both captions (small and large) appear. If I click on CC again, only the large captions disappear.
Dear @sampotts,
I'm currently facing multiple caption-related issues within my AngularJS project, specifically with a custom video player directive that utilizes the Plyr library for embedding and controlling Vimeo videos. The main problems revolve around incorrect captioning behavior.
![image](https://private-user-images.githubusercontent.com/56026691/265440664-282afc08-5b9a-4eca-999f-6866f932d9bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEzOTc0NTEsIm5iZiI6MTcyMTM5NzE1MSwicGF0aCI6Ii81NjAyNjY5MS8yNjU0NDA2NjQtMjgyYWZjMDgtNWI5YS00ZWNhLTk5OWYtNjg2NmY5MzJkOWJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE5VDEzNTIzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRmMjk2NWIyZmRkOWQ1NjZiZDU2Yzk5YmY1OGY3OWVkODUwYjg3OWU0YzY2YzFmNWI4MDQzYmRkM2VhOTk2NDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.PkE8N8L1BrX15bSQe2WLNfGx2Oy1LEO-gv1Qh1gRqYg)
Project Configuration:
Code Language: AngularJS
Video Type: Vimeo
Here is my code:
Custom Directive Creation:
`(function (base) {
'use strict';
base.directive('plyrPlayer', ['logService', '$timeout', function (logService, $timeout) {
return {
link: function ($scope, $element, $attr) {
var player;
var element = $element[0];
var secondsWatched = $attr.secondsWatched;
var showMaximized = $attr.showMaximized === "on";
var provider = $attr.plyrProvider;
}
]
);
}(lmsApp));
`
2. HTML Code Usage:
<div data-plyr-provider="vimeo" data-plyr-embed-id="849110707" plyr-player id="player" class="viewer-content" seconds-watched="secondsWatched"></div>
"~/scripts/lms/vendor/plyr.js",
I would greatly appreciate your help and guidance in resolving these caption-related issues.
Warm regards,
The text was updated successfully, but these errors were encountered: