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
Contributor
Posts: 10
Registered: ‎12-17-2010
My Device: Not Specified

Play video in tablet simulator

I use as3 to create an flv player . The code work just fine in desktop app but in simulator the flv file can not loaded ! I have tried so many way ( i have turned 3d gracphic on ) . Does anyone know why ? BTW this is my entire code :


package
{
    import flash.display.Sprite;
    import flash.events.*;
    import flash.events.MouseEvent;
    import flash.filesystem.File;
    import flash.media.Video;
    import flash.net.FileFilter;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.text.TextField;
    import flash.text.TextFormat;
    
    import qnx.ui.buttons.Button;
    import qnx.ui.buttons.LabelButton;
    
    public class TabletOSVideoDemo extends Sprite
    {
        public function TabletOSVideoDemo()
        {
            var nc:NetConnection = new NetConnection();
            nc.connect(null);
            
            var ns:NetStream = new NetStream(nc);
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
            function asyncErrorHandler(event:AsyncErrorEvent):void
            {
                // ignore error
            }
            
            var vid:Video = new Video();
            vid.attachNetStream(ns);
            ns.play("C:\lastChristmas.flv");
            addChild(vid);     
            
            var myFormat:TextFormat = new TextFormat();
            myFormat.color = 0xAA0000;   
            myFormat.size = 24;  
            myFormat.italic = true;  
            
            var textClose:TextField = new TextField();
            textClose.text = "X";
            textClose.setTextFormat(myFormat);
            
            var closeButton:Button = new Button();
            closeButton.addChild(textClose);
            closeButton.addEventListener(MouseEvent.CLICK, closeHandler);
            closeButton.width = 50;
            closeButton.x = 0
            closeButton.y = 0
            
            addChild(closeButton);
            
            function closeHandler(event:MouseEvent):void{
                stage.nativeWindow.close();
            }
        }
    }
}

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Play video in tablet simulator

hey,

 

im not too familar with the video API's (ive heard its buggy here and there) but from the look of your code, you are not properly referencing the FLV file:

 

 

ns.play("C:\lastChristmas.flv");

 

Are you packaging your video file with your application (BAR file)? If so assuming its in the same directory as your main .as file change the above code to the following and give it a shot:

 

 

ns.play(File.applicationDirectory.nativePath + "/lastChristmas.flv");

 

hope that helps. good luck!

 

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 10
Registered: ‎12-17-2010
My Device: Not Specified

Re: Play video in tablet simulator

i have tried your code ( i did put lastChristmas.flv in the same folder of my app) but the problem still there . I wonder if lastChristmas.flv must be in the hard disk of the simulator ? i have configure to share my local folder with simulator but its useless . Anyone help me ?

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Play video in tablet simulator

hey,

 

what are you using to compile and package your application?

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 10
Registered: ‎12-17-2010
My Device: Not Specified

Re: Play video in tablet simulator

i use Flash Builder 4.5 trial version . what do u mean by package ? i just create an action script mobie project and choose flex hero to compile , i just do just like the tutorial to set up enviroment

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Play video in tablet simulator

hey,

 

ah ok. i was just checking. you dont need to share any folders. whenever you place any items below your 'src' folder in Flash Builder it automatically packages the files in with your application and puts it on the device in the applicationDirectory folder. And packaging is what happens after flash builder compiles your application. so the file is there but its not playing properly. ill look into it further.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Play video in tablet simulator

hey,

 

back with an update. seems as though it was throwing errors such as a reference error. try the following updated code and let me know if it works for you:

 

 

package
{
import flash.display.Sprite;
import flash.events.*;
import flash.events.MouseEvent;
import flash.filesystem.File;
import flash.media.Video;
import flash.net.FileFilter;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.text.TextField;
import flash.text.TextFormat;

import qnx.ui.buttons.Button;
import qnx.ui.buttons.LabelButton;

public class TabletOSVideoDemo extends Sprite
{
public function TabletOSVideoDemo()
{
var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}

var vid:Video = new Video();
vid.attachNetStream(ns);
ns.client = new Object();
ns.play("lastChristmas.flv");
addChild(vid);

var myFormat:TextFormat = new TextFormat();
myFormat.color = 0xAA0000;
myFormat.size = 24;
myFormat.italic = true;

var textClose:TextField = new TextField();
textClose.text = "X";
textClose.setTextFormat(myFormat);

var closeButton:Button = new Button();
closeButton.addChild(textClose);
closeButton.addEventListener(MouseEvent.CLICK, closeHandler);
closeButton.width = 50;
closeButton.x = 0
closeButton.y = 0

addChild(closeButton);

function closeHandler(event:MouseEvent):void{
stage.nativeWindow.close();
}
}
}
}

 

the two lines i modified are the bolded lines in the code. i added the client property to prevent the application from throwing a reference errror. you should probably handle it better though in your finall application. heres a link for more details on how to:

 

http://www.adobe.com/devnet/flash/quickstart/metadata_cue_points.html

 

also when writing the file path, just use the filename.flv since its under your srce directory. if it was under another directory under your source it would just be "folder/lastChristmas.flv".

 

on a side not though when i loaded up the video it worked half way but then it stopped. it might be because of the buggy video playback on the device simulator. but the video loads and works. hope that helps! good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 10
Registered: ‎12-17-2010
My Device: Not Specified

Re: Play video in tablet simulator

thanks for your help but  it didnt work  , how sad i am ! btw , if i replace ns.play("lastChristmas.flv") with ns.play("http://ww.helpexamples.com/flash/video/cuepoints.flv") then i can play cuepoints.flv about 4 seconds in simulator! . Any Expanation ? ( you should add 1 more w at the url , because the i cant post a link here)

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Play video in tablet simulator

hey,

 

the reason why its only 4 seconds and not the entire video is because video playback is not fully supported in the simulator. last time i heard it was still being worked on. make sure that you are spelling the name of the flv file and the location is in fact under the src directroy and not under any other folder in your project. one way to confirm is by going to the bin-debug folder and if you see that your lastChristmas.flv file is there and not under any sub directories then its placed in the right place.

 

i didnt quite understand what you meant by this line: "you should add 1 more w at the url , because the i cant post a link here"

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 10
Registered: ‎12-17-2010
My Device: Not Specified