plyr icon indicating copy to clipboard operation
plyr copied to clipboard

Add markers after initialization

Open mixalistzikas opened this issue 2 years ago • 4 comments

Expected behaviour

I want to add new markers after initialization

Actual behavior

Keep showing the old markers

Steps to reproduce

defaultOptions.markers = { enabled: true, points: [{ time: 1, label: 'Label 1' }] } var player = new Plyr(video, defaultOptions); player.config.markers = { enabled: true, points: [{ time: 1, label: 'Label 1' }, { time: 2, label: 'Label 2' }] }

Environment

  • Browser: All
  • Version: 3.7.0
  • Operating System: Windows
  • Version: 11

mixalistzikas avatar Apr 18 '22 15:04 mixalistzikas

This ties back to several other issues where the config is immutable after creating the player. It's not great but it's probably not going to change but is something we'll consider for the new Vidstack player which will be Plyr's next evolution.

sampotts avatar Apr 19 '22 12:04 sampotts

@sampotts I created my own solution extending your component, so I'm ok for now. Thanks anyway

mixalistzikas avatar Apr 19 '22 12:04 mixalistzikas

@mixalistzikas

Would you be willing to share your solution to this? I also need to be able to dynamically add markers and would prefer not to have to create one from scratch if one already exists, especially since I'm on a tight schedule.

parkersprouse avatar Jul 29 '22 21:07 parkersprouse

you can add ponits with overriding .points array) something like this: player.config.markers.points = [{ time: 1, label: 'Label 1' }, { time: 2, label: 'Label 2' }]

v-stempel avatar Aug 09 '22 10:08 v-stempel

you can add ponits with overriding .points array) something like this: player.config.markers.points = [{ time: 1, label: 'Label 1' }, { time: 2, label: 'Label 2' }]

does it really work? I tried doing the same, but the view does not refresh correctly. The labels show but the marker is not visible

paradix avatar Oct 17 '22 16:10 paradix

@paradix check styles, maybe you have white timeline (markers are white by default if I'm not wrong)

v-stempel avatar Oct 18 '22 12:10 v-stempel

@paradix check styles, maybe you have white timeline (markers are white by default if I'm not wrong)

Could be I'll check again, but statically added markers are visible

paradix avatar Oct 18 '22 12:10 paradix

@paradix did you add an empty marker array to the Plyr settings?

v-stempel avatar Oct 18 '22 12:10 v-stempel

I did something like that

    player = new Plyr('#player', {
        markers: { 
            enabled: true, 
            points: [
                { 
                    time: 60,
                    label: "Test" 
                },
            ] 
        },
        volume: 0,
        invertTime: false,
    });

and than programatically

    let points = [...player.config.markers.points];
    points.push( {time: 10, label: "Test"} );
    player.config.markers.points = points;

And this results in this for the static one msedge_D9LrhAFbTI

and this for the programatic one msedge_5bdo2MZ837

paradix avatar Oct 18 '22 12:10 paradix

@paradix don't know, it works for me)

v-stempel avatar Oct 18 '22 12:10 v-stempel

@paradix don't know, it works for me)

With the same piece of code?

paradix avatar Oct 18 '22 13:10 paradix

Almost

v-stempel avatar Oct 18 '22 21:10 v-stempel

wierd as the markers are created only at this three events

on.call(player, player.media, 'durationchange loadeddata loadedmetadata', (event) =>
    controls.durationUpdate.call(player, event),
);

So the question is when are you adding markers dynamically or do you somehow force any of this events?

paradix avatar Oct 19 '22 09:10 paradix

Its possible use class markers

gitbucket-crypto avatar Nov 11 '22 14:11 gitbucket-crypto