代码之家  ›  专栏  ›  技术社区  ›  simple user

玩家立场。设置值在JWPlayer 8中未定义

  •  0
  • simple user  · 技术社区  · 7 年前

    家html

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>
        <script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="../Scripts/AngularControllers/HomeController.js"></script>
        <script src="../Scripts/Libraries/JWPlayer/jwplayer.js"></script>
        <script>jwplayer.key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"</script>
        <script src="../Scripts/AngularControllers/VideoController.js"></script>
    </head>
    <body ng-app="appHome">
        <div ng-repeat="today in todayList">
            <img ng-src="{{today.image}}" ng-click="showVideo(today.desc)">
        </div>
    </body>
    </html>
    

    HomeController。js公司

    var homeApp = angular.module("appHome", ['ui.bootstrap']);
    
    homeApp.controller("ctrlHome", ['$scope', '$uibModal', function ($scope, $uibModal) {
    
        $scope.todayList = [
            { image: 'Images/hqdefault.jpg', name: 'ABC ABC ', desc: 'Here I Am ' },
            { image: 'Images/hqdefault.jpg', name: 'DEF', desc: 'I will Rock' }
        ];
    
        $scope.showVideo = function (videoId) {
            var modalInstance = $uibModal.open({
                templateUrl: 'Video.html',
                controller: 'ctrlVideo',
                size: 'lg',
                resolve: {
                    videoId: function () {
                        return videoId;
                    }
                }
            })
        }
    }]);
    

    视频html

    <div id="myElement"></div>
    

    视频控制器。js公司

    var myApp = angular.module('appHome');
    
    myApp.controller("ctrlVideo", ['$scope', 'videoId', function ($scope, videoId) {
        var playerInstance = jwplayer("myElement");
        playerInstance.setup({
            file: "FileName",
            width: 640,
            height: 360
        });
    }]);
    

    我发现以下错误:-

    类型错误:playerInstance。设置不是一个函数

    经过进一步分析,我发现Jwplayer无法找到“ <div id="myElement"></div> “在中提到 视频html 在…内 视频控制器。js公司

    请帮助解决错误。

    1 回复  |  直到 7 年前
        1
  •  1
  •   simple user    7 年前

    我终于找到了答案。经过分析,很明显 视频控制器。js公司 然后在中定义的时间点调用“myElement” 视频html 没有加载。所以我必须使用与文档等效的东西。准备好了,我修改了 视频控制器。js公司 如下所示:-

    var myApp = angular.module('appHome');
    
    myApp.controller("ctrlVideo", ['$scope', 'videoId', '$timeout', function ($scope, videoId, $timeout) {
         $timeout(function () {
            var playerInstance = jwplayer("myElement");
            playerInstance.setup({
                file: "FileName",
                width: 640,
                height: 360
            });
        });   
    }]);