<div class="player" src="https://webtvstream.bhtelecom.ba/hls7/as_premium2.mpd"></div>

    <script>
        var HelloWorld = Clappr.UIContainerPlugin.extend({
    bindEvents() {
        this.listenTo(this.container, Clappr.Events.CONTAINER_PLAY, this.render);
    },
    render: function() {
        // Correctly format the image HTML
        this.$el.html('<img src="https://cys1d925b2.snarlgnats.top/fzbola22-icon.png" alt="Watermark" style="height: 17px; width: auto;" />');
        
        // Apply the additional CSS properties
        this.$el.css({
            'position': 'absolute',
            'width': 'auto',
            'filter': 'drop-shadow(2px 2px 2px #000)',
            'height': '17px',
            'bottom': '5px',
            'opacity': '0.75', // Use a decimal for opacity
            'left': '50%',
            'transform': 'translateX(-50%)',
        });

        this.container.$el.append(this.$el);
        return this;
    }
});

        document.addEventListener('DOMContentLoaded', () => {
            const players = document.querySelectorAll('.player');

            players.forEach(player => {
                const clapprConfig = {
                    source: player.getAttribute("src"),
                    autoPlay: player.getAttribute("auto") === "true", // Ensure it's a boolean
                    plugins: [HelloWorld, DashShakaPlayback, LevelSelector], // Corrected plugin structure
                    levelSelectorConfig: {
                        title: 'Quality',
                        labels: {
                            3: 'HD', // 700kbps
                            2: 'High', // 500kbps
                            1: 'Med', // 240kbps
                            0: 'Low', // 120kbps
                        },
                        labelCallback: function (playbackLevel, customLabel) {
                            return customLabel + playbackLevel.level.height + 'p'; // High 720p
                        }
                    },
                    width: "100%",
                    height: "100%",
                    mute: false,
                    shakaConfiguration: {
                        drm: {
                            clearKeys: {
                                'c18b6aa739be4c0b774605fcfb5d6b68': 'e41c3a6f7532b2e3a828d9580124c89d',
                            }
                        }
                    },
                };
                const clappr = new Clappr.Player(clapprConfig);
                clappr.attachTo(player);
                clappr.on(Clappr.Events.PLAYER_PLAY, function () { });
            });

            // Move media event listener outside the player loop
            var mediaOnPage = Array.prototype.slice.apply(document.querySelectorAll('audio, video'));
            mediaOnPage.forEach(function (mediumOnPage) {
                mediumOnPage.addEventListener('play', function (event) {
                    mediaOnPage.forEach(function (mediumOnPage) {
                        if (event.target != mediumOnPage) {
                            mediumOnPage.pause();
                        }
                    });
                });
            });
        });
    </script>