在时髦的地图中播放m3u8视频

时间:2018-12-31 23:54:36

标签: javascript google-maps handlebars.js video.js

我正在使用时髦的地图自定义信息窗口来显示HLS视频,但是我无法使其正常工作。视频在地图区域之外运行,但不在信息窗口本身内

  $(function() {
    // Create the map
    var map = new google.maps.Map($('.map-canvas')[0], {
        zoom: 6,
        styles: mapStyle,
        center: new google.maps.LatLng(42.7875265, -101.0458982)
    });
    var locations = [
        ['Cobram Barooga Golf Club', 40.4840985, -106.8686117]
        ];
 // Set up handle bars
    var template = Handlebars.compile($('#marker-content- 
    template').html());
if (document.getElementById("video1")) {
   videojs("video1").ready(function() {
   });
       }

for (i = 0; i < locations.length; i++) {
        marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][1], locations[i][2]),
       map: map
        });
     // Set up a close delay for CSS animations
        var info = null;
        var closeDelayed = false;
        var closeDelayHandler = function() {
            $(info.getWrapper()).removeClass('active');
            setTimeout(function() {
                closeDelayed = true;
                info.close();
            }, 300);
        };

        // Add a Snazzy Info Window to the marker
        info = new SnazzyInfoWindow({
            marker: marker,
            wrapperClass: 'custom-window',
            offset: {
                top: '10px'
            },
            edgeOffset: {
                top: 50,
                right: 60,
                bottom: 50
            },
            border: false,
            closeButtonMarkup: '<button type="button" class="custom-close"></button>',
            content: template({
                stuff:"",           
            }),
            callbacks: {
                open: function() {
                    $(this.getWrapper()).addClass('open');
                },
                afterOpen: function() {
                    var wrapper = $(this.getWrapper());
                    wrapper.addClass('active');
                    wrapper.find('.custom-close').on('click', closeDelayHandler);
                },
                beforeClose: function() {
                    if (!closeDelayed) {
                        closeDelayHandler();
                        return false;
                    }
                    return true;
                },
                afterClose: function() {
                    var wrapper = $(this.getWrapper());
                    wrapper.find('.custom-close').off();
                    wrapper.removeClass('open');
                    closeDelayed = false;
                }
            }
        });

    }
    // Open the Snazzy Info Window

  });'


 <script id="marker-content-template" type="text/x-handlebars-template">
<section>
                  <video id="video" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268">
<source src="http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8" type="application/x-mpegURL">

使用mp4时效果很好,但HLS使用m3u8 VLS提要。

有人有想法吗,或者我错了吗?

预先感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我不得不将脚本放在"message": "Expected type status, found \"accepted\"; Did you mean the enum value accepted?" 中,我只是将callback:添加到videojs("video1");中,希望这对以后的人有所帮助。