如何播放,暂停hls视频m3u8类型

时间:2018-09-04 09:23:27

标签: hls.js

是否可以在hls中播放或暂停m3u8视频类型?在页面加载中它正在播放。我正在尝试,但是当我单击按钮停止或播放时。它不会进入hls.events。它不是在播放或暂停播放

        var hls = new Hls();
        hls.loadSource(apiSessionData.vodSessionData.VideoPath);
        hls.attachMedia(video);

        $scope.playHlcVideo = function () {
            if (Hls.isSupported()) {
                console.log("hls is supported");
                console.log($scope.isPlay)

                if ($scope.isPlay) {
                    console.log('video play0')

                    hls.on(Hls.Events.MANIFEST_PARSED, function () {
                        console.log('video play')
                        video.play();
                    });
                }
                else {
                    console.log('video stop1')

                    hls.on(Hls.Events.MANIFEST_PARSED, function () {
                        console.log('video stop')
                        video.stop();
                    });
                }
                var videoDurationInfo = setInterval(function () {
                    $scope.getVideoInfo(video.duration, video.currentTime);
                }, 1000);
            } else {
                console.log("hls is not supported");
            }

第二个功能-:

            $scope.favVodFun = function () {
            console.log('fav fun registered')
            document.getElementsByClassName('video-play') 
             [0].addEventListener('click', function (inEvent) {
                console.log('console clicked')
                console.log(inEvent)
                console.log(SessionData.currentScreen.currentScreenNavStatus)
                 if (inEvent.keyCode == '13' && 
                SessionData.currentScreen.currentScreenNavStatus === 'VODPLAY') {
                console.log('console clicked enter ')
              console.log($scope.isPlay)
              console.log($scope.isFirstTimeWindowLoad)
                if (!$scope.isFirstTimeWindowLoad) {
                    if ($scope.isPlay) {
                        console.log('1111111111111111111111')
                        $scope.isPlay = false
                    }
                    else {
                        console.log('2222222222222222222222222222222')
                        $scope.showControlFunc();
                        $scope.hideControlFunc();
                        $scope.isPlay = true
                    };
                    //  };
                }
                else{
                    $scope.isFirstTimeWindowLoad=false
                }
                $scope.playHlcVideo();
            })
        };

预先感谢

0 个答案:

没有答案