MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead
Asked Answered
P

3

6

How do I fix this in the code?

This is strange, because I cannot find that in the code, but Firefox complains about that "MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead." in console.

Is there a way to fix this? I don't understand what I would need to do to fix that.

This error message appears in jsfiddle, gitHub pages, codepen.

enter image description here

https://jsfiddle.net/p5f3xc0b/3/

const videoPlayer = (function makeVideoPlayer() {
    "use strict";
    const players = [];

    function onPlayerReady(event) {
        const player = event.target;
        player.setVolume(100); // percent
    }

    let hasShuffled = false;

    function onPlayerStateChange(event) {
        const player = event.target;
        if (!hasShuffled) {
            player.setShuffle(true);
            player.playVideoAt(0);
            hasShuffled = true;
        }
        if (event.data === YT.PlayerState.PLAYING) {
            for (let i = 0; i < players.length; i++) {
                if (players[i] !== event.target) players[i].pauseVideo();
            }
        }

        const playerVars = player.b.b.playerVars;
        if (playerVars.loop && event.data === YT.PlayerState.ENDED) {
            player.seekTo(playerVars.start);
        }
    }

    function addVideo(video, settings) {
        players.push(new YT.Player(video, Object.assign({
            videoId: video.dataset.id,
            host: "https://www.youtube-nocookie.com",
            events: {
                "onReady": onPlayerReady,
                "onStateChange": onPlayerStateChange
            }
        }, settings)));
    }

    function init(video, settings) {
        load.js("https://www.youtube.com/player_api").then(function () {
            YT.ready(function () {
                addVideo(video, settings);
            });
        });
    }
    return {
        init
    };
}());

function loadPlayer(opts) {
    "use strict";

    function show(el) {
        el.classList.remove("hide");
    }

    function initPlayer(wrapper) {
        const video = wrapper.querySelector(".video");
        opts.width = opts.width || 198;
        opts.height = opts.height || 198;
        opts.autoplay = 1;
        opts.controls = 1;
        opts.rel = 0;
        opts.iv_load_policy = 3;
        opts.fs = 0;
        opts.disablekb = 1;

        function paramInOpts(settings, param) {
            if (opts[param] !== undefined) {
                settings[param] = opts[param];
            }
            return settings;
        }
        const settingsParams = ["width", "height", "videoid", "host"];
        const settings = settingsParams.reduce(paramInOpts, {});
        const playerVarsParams = ["autoplay", "cc_load_policy",
            "controls", "disablekb", "end", "fs", "iv_load_policy",
            "list", "listType", "loop", "playlist", "rel", "start"
        ];
        settings.playerVars = playerVarsParams.reduce(paramInOpts, {});
        videoPlayer.init(video, settings);
    }

    function coverClickHandler(evt) {
        const wrapper = evt.currentTarget.nextElementSibling;
        show(wrapper);
        initPlayer(wrapper);
        evt.currentTarget.classList.add("hide");
    }
    const cover = document.querySelector(opts.target);
    cover.addEventListener("click", coverClickHandler);
}
const playlist = "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g";

loadPlayer({
    target: ".jacket-left",
    width: 277,
    height: 207
});

loadPlayer({
    target: ".jacket-middle",
    width: 277,
    height: 207
});
loadPlayer({
    target: ".jacket-right",
    width: 277,
    height: 207
});

loadPlayer({
    target: ".jacketc",
    width: 600,
    height: 338,
    loop: true,
    playlist
});
loadPlayer({
    target: ".alpha",
    start: 0,
    end: 280,
    loop: true
});
loadPlayer({
    target: ".beta",
    start: 0,
    end: 240,
    loop: true
});
loadPlayer({
    target: ".gamma",
    start: 0,
    end: 265,
    loop: true
});
loadPlayer({
    target: ".delta",
    start: 4,
    end: 254,
    loop: true
});
loadPlayer({
    target: ".epsilon",
    start: 0,
    end: 242,
    loop: true
});
loadPlayer({
    target: ".zeta",
    start: 0,
    end: 285,
    loop: true
});
loadPlayer({
    target: ".eta",
    start: 23,
    end: 312,
    loop: true
});
loadPlayer({
    target: ".theta",
    start: 2
});
loadPlayer({
    target: ".iota"
});
Poston answered 31/8, 2019 at 1:22 Comment(0)
L
4

As Marci answered on another forum, this warning comes from the YouTube embed. It is actually triggered anytime you visit youtube.com in Firefox. The relevant code is on line 1355 of desktop_polymer_inlined_html_polymer_flags_v2.js.

Labefaction answered 12/4, 2020 at 17:5 Comment(0)
A
2

The error might be coming from something else. It is just a warning, and because it has nothing to do with your code, I wouldn't worry about it. If you go on most websites, even they have error messages in the console that don't affect what you are doing in any way. If everything you are doing is working, I wouldn't worry about it. Good luck, this looks like a cool project!

Archaize answered 31/8, 2019 at 3:0 Comment(1)
even youtube has itGord
S
1

It is a warning, not an error. It seems like your code still works... But to get rid of the warning, you can use a try-catch block. I can't identify where your warning is coming from, as I do not get the error. If you specify the line, I can add the try-catch for you.

Search answered 31/8, 2019 at 2:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.