Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook

JWPlayer inside HTML5 Application

I can't seem to get my embedded player to work, sample code below:

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Test</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.swfobject.1-1-1.min.js"></script>
    <script type="text/javascript">
        var player;

        function init() {

            var flashvars = {
                id:"player1",
                screencolor:"000000",
                controlbar:"false",
                autostart:"false",
                bufferlength:3,
                backcolor:"EFEFEF",
                frontcolor:"000000",
                provider:"video"
            };
            var params = {
                allowfullscreen:"true",
                allowscriptaccess:"always"
            };
            var attributes = {
                id:"player1",
                name:"player1"
            };

            var width = "600";
            var height = "360";

            flashMovie = jQuery('#player1');

            flashMovie.flash(
                    {
                        swf: 'flash/jw-player-5.10.swf',
                        width: width,
                        height: height,
                        flashvars: flashvars,
                        params: params
                    }
            );
        }

        function playerReady(thePlayer) {
            player = $("#player1")[0].childNodes[0];
            play();
        }

        function play() {
            if (!player) {
                player = $("#player1")[0].childNodes[0];
            }
            var list = new Array();
            var currentID = 77;
            var duration = 2233;
            var videoURL = 'http://domain.com/video.flv';

            list[0] = {
                file:videoURL,
                duration:duration,
                provider:'video'
            };
            player.sendEvent('LOAD', list);
            player.sendEvent('PLAY');
        }

        function TimeListener(obj) {
            var newPosition = Math.round(obj.position);
            if (newPosition != position) {
                position = newPosition;
                UpdatePosition();
            }
        }

        function UpdatePosition() {
            var pos = getPosition();

            var minutes = Math.round(pos / 60);
            var seconds = pos % 60;

            var result = minutes + ":";
            if (seconds < 10) {
                result += "0";
            }
            result += seconds;
        }
    </script>
</head>
<body onload="init();">
<div id="wrapper">
    <div id="player1"><a href="http://www.adobe.com/go/getflashplayer" target="_blank">Get Flash player</a></div>
</div>
<button id="play_button" onclick="play();">Play</button>
<button id="pause_button">Pause</button>
</body>
</html>

 This works perfect in the PB browser but not when packaged and signed as an app. The playerReady event that normally fires doesn't and when I try on the browser:

$('player1')[0].childNodes[0].sendEven('play');

 That works but it doesn't as an app.

 

Help would be greatly appreciated!

 

Thanks,

Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: JWPlayer inside HTML5 Application

[ Edited ]

You have a lot of external domains in the code.  Have you "whitelisted" them in your config.xml?  Check out the access tag in the documentation.  Something like:

 

<access uri="http://www.somedomain.com" subdomains="true">
    <feature id="blackberry.app.event"/>
    <feature id="blackberry.invoke"/>
  </access>

 

 

If it helped you, click like. :smileyhappy:
Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook

Re: JWPlayer inside HTML5 Application

Everything but the videoURL is whitelisted.

 

The videoURL is custom depending on the user - also it never gets to that, the JS stops working well before we get to that URL.

BlackBerry Development Advisor
Posts: 165
Registered: ‎09-24-2012
My Device: Passport

Re: JWPlayer inside HTML5 Application

Hi nomi34,

 

Can you share out the source code? The example is incomplete. You can contact me offline if you don't want to post a public link.

Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook

Re: JWPlayer inside HTML5 Application

Hi Anzor I can send you the source code for sure - could you send me your email: omar [at] gmail [dot] com

And I will send you the sourcecode, a working website example and I can provide you with also a test account to the api I'm dealing with where I get the video.

Thanks!
BlackBerry Development Advisor
Posts: 165
Registered: ‎09-24-2012
My Device: Passport

Re: JWPlayer inside HTML5 Application

hi nomi34,

 

Tried to email you, but getting undeliverable. Can you check the email address again please?

Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook

Re: JWPlayer inside HTML5 Application

Oh my apologies! Its:
omarmir [at] gmail [dot] com

Messed up work email alaises and domains.