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
New Contributor
Posts: 6
Registered: ‎08-26-2012
My Device: Playbook
My Carrier: none

callback function, audio-video, keeping playbook awake...

Can someone tell me why the simplest callback function cannot work in Playbook Browser?

 

function gong() {
        var z = document.getElementById("gong").play();
        z.addEventListener("ended", callback() ,false);

}

 

function callback(){
    var v = document.getElementById("vid");
     v.play()

}

 

This works perfectly well in Chrome.

I explain what I tried to do...

I tried to make a meditation timer application. Now I know there is none of a proper meditation app on appworld because playbook goes into sleep after max. 5 min. and timer doesn't work in the background.

So I read about possibility to put looped video inside the app. Unfortunatelly I spent whole day trying to figure out how to play video after audio, or both together, and every kind of code which works in chrome,ff doesn't in playbook browser.

My app works great on android, but I bet since there's no application like that, the android runtime will still be unable to keep the playbook awake. Correct me if I am wrong?

 

I would be glad to hear some fresh thought, how to do it, because now I am completely frustrated and forgive me, but so angry on BB, which I was so enthusiastic about...

 

BTW, this is the simplest route, which doesn't work on playbook either:

 

<video id="vid" width="2" height="2"  muted loop >
  <source src="t.mp4" type="video/mp4" />

</video>

 

.... onclick="setTimeout ( function () {.....})  "

 

Video stops, when Timeout function calls this:

...document.getElementById(...).innerHTML='<embed src="bell-tone.mp3" hidden="true" autostart="true"></embed>';

Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: callback function, audio-video, keeping playbook awake...

Hi.

 

Did you use Web Inspector to debug your source code? There seems to be an issue in your source code since you are using this:

 

z.addEventListener("ended", callback(),false);

It should be this:

 

z.addEventListener("ended", callback,false);

Can't understand why Chrome isn't reporting an error using the first way.

 

The problem with keeping the PlayBook awake can be the same, but it doesn't inevitably. Let us know about your progress.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: callback function, audio-video, keeping playbook awake...

In addition to LBP's recommendations which I agree with, I'm a little skeptical of the audio code.

 

var z = document.getElementById("gong").play();
z.addEventListener("ended", callback() ,false);

You're setting variable z to the result of play, which I would not expect to return the DOM element (though I haven't been able to find the exact specification for play.)

 

I would expect this to require the following approach.

 

var z = document.getElementById("gong");
z.addEventListener("ended", callback, false);
z.play();

 

Here, we grab the actual DOM element, add the event listener before we start playing, and then call play.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Highlighted
New Contributor
Posts: 6
Registered: ‎08-26-2012
My Device: Playbook
My Carrier: none

Re: callback function, audio-video, keeping playbook awake...

actually I've found an answer

PlayBook currently only supports 1 active channel for HTML5 audio

so whatever I would change in code it won't work.

I didn't expect that, this is some crazy os development...

 

I don't understand though why two separated audio files, where one is muted can't play either.

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: callback function, audio-video, keeping playbook awake...

Hi there,

 

Which PlayBook OS version are you on? Multi-channel audio should be supported in the latest builds.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Contributor
Posts: 6
Registered: ‎08-26-2012
My Device: Playbook
My Carrier: none

Re: callback function, audio-video, keeping playbook awake...

2.0.1.358

 

I understand it is now fixed in

http://devblog.blackberry.com/2012/05/blackberry-playbook-2-1-0-beta/

 

but I want to develop for people not developers, and it's now ^ 3 months later.

Or am I missing something? My playbook says it' has current os installed.

It seems pointless to finish app now, since playbook will upgrade anyway to bb10 sooner or later, right??

 

So I'm curious, in Blackberry 10 webworks is it possible to play mutiple html audio/video content??

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: callback function, audio-video, keeping playbook awake...

You are correct that the latest public version of the PlayBook OS is 2.0.1.358.

 

HTML5 functionality that exists on the PlayBook will be available in BlackBerry 10 when it is released, and the PlayBook will be upgradeable to BlackBerry 10 but I can not give any specific timelines there.

 

I'm not sure that I follow the logic that it is pointless to finish the application though. Improving the application for the developer build of the OS means you're ready to launch/update when the public release gets updated.

 

On top of that, the applications that you develop today will also run on BlackBerry 10; there may be some changes, including at the API-level in some cases, but the majority of applications will simply work. Building your application now means you're ready to go on Day 1.

 

I guess ultimately it comes down to what your goals are for the app.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.