简体   繁体   English

将Jplayer视频播放与Angular.JS集成

[英]Integrating Jplayer video playback with Angular.JS

I'm working with a framework based on angular.js. 我正在使用基于angular.js的框架。 I need to playback video and an iframe is off the menu per my customer's specifications. 我需要播放视频,但根据客户的要求,iframe不在菜单中。

I am trying to get jPlayer video playback working. 我正在尝试使jPlayer视频播放正常。 I have seen c0deformer's solution and I have it integrated already as an audio player, but for my newest project they definately need video playback. 我已经看到了c0deformer的解决方案,并且已经将其集成为音频播放器,但是对于我的最新项目,他们肯定需要视频播放。 When I start my jPlayer instance, I get the following error: 启动jPlayer实例时,出现以下错误:

pre-call ClosureCompiler.script:1
post-call ClosureCompiler.script:1
TypeError: Cannot read property 'childNodes' of undefined
    at e (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:38:220)
    at e (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:38:215)
    at e (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:38:215)
    at k (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:42:261)
    at http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:46:471
    at k (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:42:261)
    at http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:46:458
    at http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:91:245
    at h (http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:75:256)
    at http://arielsmamma/rsrc/3rdparty/angular-1.0.1.min.js:75:489 angular-1.0.1.min.js:60
pre-setmedia-call ClosureCompiler.script:1
post-setmedia-call 

Here is the jPlayer code: 这是jPlayer代码:

(function()
{
    itx.ns( 'ui.video.jPlayerVideo', jPlayerVideo, true );
    itx.extend( jPlayerVideo, itx.Directive,
    {
        restrict: 'E',
        replace: true,
        name: 'itx-jPlayer-video',
        scope: {
            'src': '=',
            'duration': '='
        }
    });


    function jPlayerVideo($scope)
    {
        itx.Directive.apply( this, arguments );
        var self = this;
        console.log('pre-call');
        $("#jp_container_1").jPlayer({
            swfPath: '../rsrc/3rdparty/jplayer/',
            solution: 'flash, html',
            supplied: 'm4v',
            ready: function () {
                console.log('pre-setmedia-call');
                $(this).jPlayer("setMedia", {
                    m4v: $scope.src
                });
                console.log('post-setmedia-call');
            }
        });
        console.log('post-call');
    }
})()

I hope I've given enough information! 希望我能提供足够的信息!

FWIW,当我回到这个话题时 ,我决定尝试其他替代方法,并且发现videoJS开箱即用。

Maybe you should provide a simple example on JsFiddle: http://jsfiddle.net/ 也许您应该在JsFiddle上提供一个简单的示例: http : //jsfiddle.net/

Without an live example it's hard to test the code. 没有实际的示例,很难测试代码。

Aside of that, I've notices the line: 除此之外,我注意到这一行:

name: 'itx-jPlayer-video',

I suppose this is your directive? 我想这是你的指令? I'm not sure, but shouldn't it be 'itxJPlayerVideo'? 我不确定,但是不应该是“ itxJPlayerVideo”吗?

Directives have camel cased names such as ngBind. 指令具有驼峰式的名称,例如ngBind。 The directive can be invoked by translating the camel case name into snake case with these special characters :, -, or _. 可以通过将驼峰大小写名称转换为带有以下特殊字符:,-或_的蛇形大小写来调用该指令。

See http://docs.angularjs.org/guide/directive 参见http://docs.angularjs.org/guide/directive

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM