Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript playerInstance.setup值在JWPlayer 8中未定义_Javascript_Html_Angularjs_Jwplayer - Fatal编程技术网

Javascript playerInstance.setup值在JWPlayer 8中未定义

Javascript playerInstance.setup值在JWPlayer 8中未定义,javascript,html,angularjs,jwplayer,Javascript,Html,Angularjs,Jwplayer,在Angular JS中打开模式中的JW Player 8时,我遇到了问题 Home.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="

在Angular JS中打开模式中的JW Player 8时,我遇到了问题

Home.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>
<div id="myElement"></div>
Video.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>
<div id="myElement"></div>
我得到以下错误:-

TypeError:playerInstance.setup不是一个函数↵

进一步分析后,我发现Jwplayer无法在VideoController.js页面中找到Video.html中提到的“


请帮助解决错误。

我终于得到了答案。分析后很明显,当调用VideoController.js时,在Video.html中定义的“myElement”没有加载。因此,我必须在Angular JS中使用与document.ready等效的东西,并修改了VideoController.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
        });
    });   
}]);