Pause player by JavaScript


I’m trying to pause the player by JavaScript. Somehow I can’t figure that out.

Can somebody help?

1 Like

Hi @peter.vanvogelpoel

Assuming you have configured your player with something like this

var player = new bitmovin.player.Player(document.getElementById('player'), conf);

then (if I’m not missing something obvious) you should be able to use e.g.:

<button id="myBtnPause">Pause</button>
<button id="myBtnPlay">Play</button>
    const element1 = document.getElementById("myBtnPause");
    element1.addEventListener("click", myFunction);

    function myFunction() {

    const element2 = document.getElementById("myBtnPlay");
    element2.addEventListener("click", myFunction);

    function myFunction() {;



Hi Peder,

Thanks. But I don’t get it to work.
My project is a Blazor WASM project. In my script file I have the following:

function setupBitmovinPlayer(playername, videoname, urlStreamingLink) {
var conf = {
key: ‘xxx’

var source = {
    title: videoname,
    progressive: urlStreamingLink

var player = new bitmovin.player.Player(document.getElementById(playername), conf);


This works fine.

Then I have:

function pausePlayer() {

From the Razor page I run:


This reaches the function. But nothing happens.

Any advise?

Hi Peter,
are you sure your pausePlayer() function has access to the player variable? Looks from your example as the player is only scoped to the setupBitmovinPlayer function thus when you call the other function it won’t be able to resolve the reference.

Try defining the player in a larger scope that should fix the issue.

greetings Daniel

That’s what I figured. But I’m not sure how to do that.

Any advise on how to do this in Blazor?

Figured it out allready.

I had to put the player var in a script in the index.html and place a hidden player wrapper in there as well.

Then change this var through js functions on the relevant pages.

That worked for me. Maybe there are better ways.

1 Like