How to update jPlayer title?

463 views Asked by At

I'm trying to update the display title of a jPlayer object (encircled in red), after the jPlayer object has already been instantiated with a different audio file.

jPlayer object example

I'm using the following code, which doesn't seem to be working:

$("#jplayer-id").jPlayer("setMedia", {
    title: "NEW TITLE"
});

What am I missing? Thanks.

1

There are 1 answers

6
jrbedard On BEST ANSWER

Try this for setMedia setting the title within the jPlayer ready event:

$("#jplayer-id").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            title: "NEW TITLE",
        });
    },
});

If already initialized, you can use jQuery to target its jp-title class.

$("#jplayer-id .jp-title").text("NEW TITLE");