Hi, i'm trying to integrate JWplayer into my app. My setup is Jwplayer 7.12.8 + enabled sharing + enabled related from external RSS file.
Player initiation is here: https://pastebin.com/QxAer18R
Related endpoint returns: https://pastebin.com/H8CZF6Vx
Scenario There is a player on page. The share buton is enabled and i can share with "some-current-url" address. When playing is finished i can choose from two related videos. Then player starts playback and share button is still enabled. After I press it, the share link is still "some-current-url" instead of "somelink8544" or "somelink8511" which i expected.
At this moment i'm going to create simple example, to check all features that i need.
For now, it's just a hardcoded string. I guess it should be string with current url address but to simplify i set hardcoded string 'some-current-url' as sharing link.
Forgive me but I am a little confused – if you set the sharing link to a string, “some-current-url”, then that is what the option will be set to. If you set it to a URL, then the sharing link would be the URL.
What is strange for me - I can not set share url for each of related video (or I don't know how to do it).
Currently I setup player for video and set share url as 'some-current-url'. I need to set different share link for each of related video. How can I achive that?
URL "/related/id,MEDIAID.html" is an endpoint in my application that returns related playlist for given MEDIAID file. You can check sample output here - https://pastebin.com/H8CZF6Vx .
I have started debuging sharing.js plugin. I have got access to minified file only but I think i have found function that return share link for every video.
function i(C, e) { var n = C.indexOf("MEDIAID"); return n > 0 && e ? C.replace("MEDIAID", e) : n === -1 ? C : void 0 } function a(C) { var e = window.location.toString(); if (window.top !== window && (e = document.referrer), n.link) { var t = i(n.link, C); e = t ? t : e } return e }
Variable C is id of media, n is sharing-plugin options, in my case:
{ "link": "some-current-url" }
In my opinion, there is only one method to set share url for related video - using MEDIAID token.
It looks like the permalink set in the dashboard will only be used in the sharing overlay if you embed the player with a single-line embed code generated by the dashboard. I did come up with a workaround that seems to work:
playerInstance.on("playlistItem", function(e) {
var playerElement = playerInstance.getContainer();
var linkIcon = playerElement.querySelector(".jw-sharing-icon-link");
var link = linkIcon.parentNode.querySelector(".jw-sharing-textarea");
link.removeAttribute("readonly");
setTimeout(function() {
link.textContent = playerInstance.getPlaylistItem().link;
}, 1000);
});
The above is assuming var playerInstance = jwplayer('whateverYourPlayerElementsIdIs");
First of all - your solution works :) Thanks for that.
I personally do not like solutions that use setTimeout function - there are not elegant but I understand that it's just a workaround and it's only way to achieve my goal.
I have made some changes in your code. This is how it looks right now:
player.on("playlistItem", function (e) {
var playerElement = player.getContainer(); var linkIcon = playerElement.querySelector(".jw-sharing-icon-link"); var link = linkIcon.parentNode.querySelector(".jw-sharing-textarea"); link.removeAttribute("readonly"); setTimeout(function () {
This solution resolve only problem of copy link option in share plugin. Other options like facebook, twitter still use default url addres. To override it, I have changed my jwplayer setup like this: