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

Adobe AIR Development

Reply
New Contributor
applauz
Posts: 9
Registered: ‎05-01-2011
My Device: PlayBook

qnx.media.VideoDisplay does not work [HELP]

[ Edited ]

I have tried everything to make this work. Even the example given by RIM doesn't work. It causes the app to freeze on the splash screen.

 

I'm using OS 2.0 on the PlayBook

 

The strange thing is that it freezes only when you declare your variable.

 

ie/  If I declare my variables

 

var myVD:VideoDisplay;
var myPlayer:MediaPlayer;

 

This causes the app to freeze at the startup screen.

 

If I remove those variables...  it doesnt freeze... but obviously wont do anytinng else.

 

 

 

Here is my code..

 

--

 

import qnx.events.MediaPlayerEvent;

import qnx.media.MediaPlayer;

import qnx.media.VideoDisplay;
import qnx.ui.events.MediaControlEvent;
import qnx.ui.media.*;

 

var myVD:VideoDisplay;
var myPlayer:MediaPlayer;

 

 

function loadQNXVideo():void{
    
  isVideo = "yes";

            myVD = new VideoDisplay(false);
            
            myVD.setPosition(1024/2 - 800/2, 600/2 - 480/2);
            myVD.setSize(800, 480);
            myVD.backgroundColor = 0x000000;
            addChild(myVD);
            
            myPlayer = new MediaPlayer();
            //_myPlayer.addEventListener(MediaPlayerEvent.INFO_CHANGE, infoChange);            
            myPlayer.url = "/filename.mp4";          
            myPlayer.videoDisplay = myVD;

playerControls.visible = true;

//webView2.addEventListener(Event.COMPLETE,handleLoad);

}

 

 

 

New Contributor
applauz
Posts: 9
Registered: ‎05-01-2011
My Device: PlayBook

Re: qnx.media.VideoDisplay does not work [HELP]

Anyone ?

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: qnx.media.VideoDisplay does not work [HELP]

Is this in some class? It might default to some kind of scope (never tried without it), but should'nt this be "private var ..."?
New Contributor
applauz
Posts: 9
Registered: ‎05-01-2011
My Device: PlayBook

Re: qnx.media.VideoDisplay does not work [HELP]

This isnt in an external .as  file.  It's in the Flash IDE so variables arent Public and Private.

Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: qnx.media.VideoDisplay does not work [HELP]

Well, sounds like some sort of verification error, you include the clas, run the app... AIR can not find the class, BOOM blows up.

 

Are you not getting any debug error's?

Developer
Deepu_George_Jacob
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380

Re: qnx.media.VideoDisplay does not work [HELP]

/*
* A simple "Hello, World" example that demonstrates use of an
* application-modal dialog to prompt for the user's name and
* echo it in a greeting.
*/

package
{
import flash.display.Sprite;
import flash.filesystem.File;

import qnx.events.MediaPlayerEvent;
import qnx.media.MediaPlayer;
import qnx.media.VideoDisplay;
import qnx.ui.events.MediaControlEvent;
import qnx.ui.media.*;

[SWF(height="600", width="1024", frameRate="30", backgroundColor="#BBBBBB")]
public class MediaPlayerSamplel extends Sprite
{
public var _myPlayer:MediaPlayer;
public var _myVD:VideoDisplay;
public var _myMediaControl:MediaControl;

public function MediaPlayerSamplel()
{
initializeUI();
initializePlayer();
}

public function initializePlayer():void
{

_myVD = new VideoDisplay;
_myVD.setPosition(1024/2 - 800/2, 600/2 - 480/2);
_myVD.setSize(800, 480);
_myVD.backgroundColor = 0x000000;
addChild(_myVD);

_myPlayer = new MediaPlayer();
_myPlayer.addEventListener(MediaPlayerEvent.INFO_CHANGE, infoChange);
var file:File = File.userDirectory.resolvePath("sample_media_url.mp4");
_myPlayer.url = file.nativePath;
_myPlayer.videoDisplay = _myVD;

}

public function initializeUI():void
{

_myMediaControl = new MediaControl();
_myMediaControl.width = 900;
_myMediaControl.x = Math.round((stage.stageWidth - _myMediaControl.width) / 2);
_myMediaControl.y = stage.stageHeight - _myMediaControl.height;

_myMediaControl.setOption( MediaControlOption.VOLUME, true );
_myMediaControl.setOption( MediaControlOption.PLAY_PAUSE, true );
_myMediaControl.setOption( MediaControlOption.NEXT, true );
_myMediaControl.setOption( MediaControlOption.PREVIOUS, true );
_myMediaControl.setOption( MediaControlOption.STOP, true );
_myMediaControl.setOption( MediaControlOption.SEEKBAR, true );
_myMediaControl.setOption( MediaControlOption.DURATION, true );
_myMediaControl.setOption( MediaControlOption.POSITION, true );
_myMediaControl.setOption( MediaControlOption.BACKGROUND, true);
_myMediaControl.setProperty( MediaControlProperty.VOLUME, 80 );

_myMediaControl.addEventListener( MediaControlEvent.STATE_CHANGE, mediaControlStateChange );
_myMediaControl.addEventListener( MediaControlEvent.PROPERTY_CHANGE, mediaControlPropChange );

addChild(_myMediaControl);

}

public function infoChange(event:MediaPlayerEvent):void {

if (event.what.position) {
_myMediaControl.setProperty(MediaControlProperty.POSITION, _myPlayer.position);
}
if (event.what.duration) {
_myMediaControl.setProperty(MediaControlProperty.DURATION, _myPlayer.duration);
}
if (event.what.state) {
_myMediaControl.setState(_myPlayer.isPlaying ? MediaControlState.PLAY : MediaControlState.PAUSE);
}

}

public function mediaControlStateChange(mediaControlEvent:MediaControlEvent):void
{
var state:smileyfrustrated:tring = _myMediaControl.getState();

switch( state )
{
case MediaControlState.PLAY:
if (!_myPlayer.isPlaying)
{
_myPlayer.play();
}
else
{
_myPlayer.speed = 1000;
}
break;
case MediaControlState.PAUSE:
_myPlayer.pause();
break;
case MediaControlState.STOP:
_myPlayer.stop();
break;
case MediaControlState.SEEK_START:
_myPlayer.pause();
break;
case MediaControlState.SEEK_END:
_myPlayer.play();
break;
default:
break;
}
}

public function mediaControlPropChange(event:MediaControlEvent):void {

switch (event.property) {

case MediaControlProperty.POSITION:
{
_myPlayer.seek(uint( _myMediaControl.getProperty(MediaControlProperty.POSITION)));
}
break;
case MediaControlProperty.DURATION:
break;
case MediaControlProperty.FULLSCREEN:
break;
case MediaControlProperty.VOLUME:
break;
default:
break;
}
}

}


}