[Red5] Re : Re : Re : Re : Re : Réf.: play a saved Video
Walter Tak
walter at waltertak.com
Tue Jul 21 09:42:27 PDT 2009
You placed the declaration of videoRemote at a good position now.
Make it a private variable if you don't intend to expose the var outside the class but that doesn't matter for the functionality at this point.
I wouldn't use addChild in the function 'startStream' since it would add the videoObject over and over again if you'd call the function startStream more than once.
Just add the videoObject to the stage once in the constructor of a class that acts as a singleton.
Look at startStream if see that you se the argument [this.startStream(streamName);] but I can't see where streamName is being filled. Doesn't the compiler give warnings about streamName not being declared ?
Do a trace or an alert to show var [val] inside your function startStream.
You also call your class [VideoSubscriberUser] with a parameter for the constructor but the code doesn't show any constructor function at all.
I'd recommend to go to www.pastebin.org and paste your code in full on there, make it availabe for a month or so (long enough and safe) and highlight actionscript syntax for easier reading.
----- Original Message -----
From: Etienne Bonnefoy
To: red5 at osflash.org
Sent: Tuesday, 21 July 2009 18:06
Subject: [Red5] Re : Re : Re : Re : Re : Réf.: play a saved Video
OK, I think I understand what you mean, but I'm not able to see where I have to declare my Video object.
Here is how I build my application:
1) MXML file: access.mxml => In this file I have a function inside a script:
private function accessProfile(evt:MouseEvent) : void
{
leNom = theloginTest.usernameField.text; // Gives me the name of current user
var leProfile:ProfilePerso = new ProfilePerso(leNom); // Calls for the Class ProfilePerso
PopUpManager.addPopUp(leProfile,this); //Add this object as a popUp
}
1) a ProfilePerso.as Class:
import VideoSubscriberUser;
public var leVideo:VideoSubscriberUser;
With a function
public function publishRecorded():void
{
laVideo= new VideoSubscriberUser("IronMan.flv"); // There I call my Video Object
laVideo.width = 230;
laVideo.height = 230;
laVideo.move(5,5);
lePanel.addChild(laVideo);
Alert.show(laVideo.leBoutton.x.toString() , "XXXXXXXXXXXX");
}
3) a Class: VideoSubscriberUser.as
import flash.media.Video;
import flash.net.NetStream;
import jedai.net.rpc.Red5Connection;
public var leStream : NetStream;
public var videoRemote:Video;
private var _outputDevice:VideoOutputDevice;
With the following functions
public function startStream(val:String) : void {
leStream = new NetStream(_connection);
leStream.bufferTime = 3;
leStream.receiveAudio( true );
leStream.receiveVideo( true );
//
leStream.client = this;
videoRemote = new Video( 120, 120 );
videoRemote.attachNetStream( leStream );
this.addChild(videoRemote);
//
leStream.play( val );
}
private function onCreationComplete(event:FlexEvent) : void {
_connection = Red5ServiceLocator.getInstance().getRed5Connection("default");
Alert.show(_connection.uri.toString(),"LLLLAAAA CCCOOONNNEEECCCTTTIIIOOOONNN");
leBoutton.addEventListener(MouseEvent.CLICK, OnSubmitVideo);
}
private function OnSubmitVideo(evt:MouseEvent) : void
{
switch(leBoutton.label) {
case "Start Video":
this.startStream(streamName);
break;
case "Stop Video":
this.stopStream();
break;
default:
break;
}
override protected function createChildren():void {
super.createChildren();
if (!_outputDevice)
{
//_outputDevice = new Video();
_outputDevice = new VideoOutputDevice();
_outputDeviceWrapper = new UIComponent();
_outputDeviceWrapper.addChild(_outputDevice);
this.addChild(_outputDeviceWrapper);
}
if (!leBoutton)
{
leBoutton = new Button;
leBoutton.label = "Start Video";
leBoutton.move(25,25);
leBoutton.width = 120;
leBoutton.height = 30;
this.addChild(leBoutton);
}
}
Is there any object I should declare outside a function and I did not?
Otherwise, is there any object I miss to display correctly my video?
If you want to discusse more about my problem, maybe there is a easier way than the Red5 mailling list, not?
you can write me directly on my yahoo account.
Thanks for your time.
Regards,
Etienne.
------------------------------------------------------------------------------
De : Walter Tak <walter at waltertak.com>
À : red5 at osflash.org
Envoyé le : Mardi, 21 Juillet 2009, 17h33mn 23s
Objet : Re: [Red5] Re : Re : Re : Re : Réf.: play a saved Video
Nah I meant that if you instanciate a Video object in Flash inside a function it will be lost when the function exits. Same problem you had with the "leStream" NetStream-object. Declare the video-object outside the function.
----- Original Message -----
From: Etienne Bonnefoy
To: red5 at osflash.org
Sent: Tuesday, 21 July 2009 15:27
Subject: [Red5] Re : Re : Re : Re : Réf.: play a saved Video
Hello Walter,
sorry but I don't know how to manage Scope. I have tried to find some tutorials or courses about the use of Scope but never found anything on this topic.
There for I don't know how to use Scope, how to configure them, in which directory I can find them...and everything I could do with scopes.
Actually, on my project, I never created any scope. I'm using an existing project in which it was possible to publish video in "live" mode from a camer and to share it with avery connected users.
Could you give me a clue on how to use Scopes or how to verify that my scope is correct, please?
Thank you.
Regards,
Etienne.
----------------------------------------------------------------------------
De : Walter Tak <walter at waltertak.com>
À : red5 at osflash.org
Envoyé le : Lundi, 20 Juillet 2009, 17h46mn 07s
Objet : Re: [Red5] Re : Re : Re : Réf.: play a saved Video
You know there is a possible scope problem with variable [videoRemote] as well ?
Better declare that outside the function.
----- Original Message -----
From: Etienne Bonnefoy
To: red5 at osflash.org
Sent: Monday, 20 July 2009 17:09
Subject: [Red5] Re : Re : Re : Réf.: play a saved Video
Hello again,
here are the information you asked about the connection(with My code...I am trying the pastebin.org code rifht now). It is my Console information:
///On connection:
onNetStatus: NetConnection.Connect.Success
event: [Event type="connected" bubbles=false cancelable=false eventPhase=2]
[SWF] /TestJedai1Client/TestJedai1Client.swf - 196 bytes after decompression
///When trying to start Video:
2009-07-20 16:54:23,093 [pool-4-thread-15] INFO org.red5.server.jmx.JMXFactory - Object name: org.red5.server:type=Client,id=12
2009-07-20 16:54:23,093 [pool-4-thread-15] INFO org.red5.server.jmx.JMXFactory - Object name: org.red5.server:type=RTMPMinaConnection,connectionType=persistent,host=localhost,port=1935,clientId=12
2009-07-20 17:05:41,484 [pool-4-thread-15] INFO org.red5.server.stream.ProviderService - getVODProviderFile scope path: name: IronMan.flv
2009-07-20 17:05:41,484 [pool-4-thread-15] INFO org.red5.server.stream.ProviderService - getStreamFile null check - factory: org.red5.io.StreamableFileFactory at 2b7bd9 name: IronMan.flv
///When closing the connection:
onNetStatus: NetConnection.Connect.Closed
event: [Event type="disconnected" bubbles=false cancelable=false eventPhase=2]
And Actually, I managed to avoid starting video if the connection is not set to "connected":
if ( _connection.connected != true )
Alert.show("It is not possible to play video if not connected!!! Connect first");
I don't know if it helps you with your investigation or not...
Regards,
Etienne.
--------------------------------------------------------------------------
De : Walter Tak <walter at waltertak.com>
À : red5 at osflash.org
Envoyé le : Lundi, 20 Juillet 2009, 16h54mn 04s
Objet : Re: [Red5] Re : Re : Réf.: play a saved Video
Check out this example: http://www.pastebin.org/2940
It shows event handlers for the NetConnection ; perhaps your connect goes wrong and then a video won't be played.
Make sure you see at least a NetConnection.Connection.Success event
Btw paste your client AS3 code on www.pastebin.org so we can see how your _connection variable looks like.
Also check the logs / console of your Red5 server. You should see an incoming connection in the logs when you try to connect from Flash.
----- Original Message -----
From: Etienne Bonnefoy
To: red5 at osflash.org
Sent: Monday, 20 July 2009 16:15
Subject: [Red5] Re : Re : Réf.: play a saved Video
Hello Walter,
I have just tried to create "leStream" as a public Class variable.
Unfortunatelly, still the same result. I still have a white screen with a "TTHHEE TTTIIIMMEE" equal to "0" => It doesn't detect any .flv file...
Is there any way to trace if I get my Movie file? Or at least to see where this application tries to get the Movie file?
Thank you.
Regards,
Etienne.
------------------------------------------------------------------------
De : Walter Tak <walter at waltertak.com>
À : red5 at osflash.org
Envoyé le : Lundi, 20 Juillet 2009, 15h55mn 30s
Objet : Re: [Red5] Re : Réf.: play a saved Video
You might run into Flash scoping problems ; you create a new NetStream inside function startStream and guess what happens when the function finishes. Right the instanced NetStream "leStream" will be removed.
Thus create leStream outside the function.
----- Original Message -----
From: Etienne Bonnefoy
To: red5 at osflash.org
Sent: Monday, 20 July 2009 15:38
Subject: [Red5] Re : Réf.: play a saved Video
Hello Andy,
here is what I tried.
//VideoSubscriberUser is a class that is called and that enables the reading of Videos.
//function to start the streaming:
public function startStream(val:String) : void {
var leStream : NetStream = new NetStream(_connection);
leStream.bufferTime = 3;
leStream.receiveAudio( true );
leStream.receiveVideo( true );
leStream.client = this;
Alert.show(leStream.time, "TTHHEE TTIIMMEE:::");
var videoRemote:Video = new Video( 120, 120 );
videoRemote.attachNetStream( leStream );
leStream.play( val );
}
//Creating my object that will enable reading my video:
var laVideo:VideoSubscriberUser = new VideoSubscriberUser("IronMan.flv");
It still doesn't work...
==>> When I run a debugging I can see that my function is well called, and that every function included are called too. Unfortunatelly, I cannot get any info about the Video that I want to read (the Alertmessage about time is "0", meaning that no video has been found...). I have putted my video in lot of different folders but I never read it...
In which folder should I put my video? On my Java directory (server side) or in my AS3 folders (Flex side).
Is there any way (AS3 Command) to see in which directory I try to get my .flv file?
Thank you for your help.
Regards,
Etienne.
----------------------------------------------------------------------
De : Andy Shaules <bowljoman at hotmail.com>
À : red5 at osflash.org
Envoyé le : Samedi, 18 Juillet 2009, 10h26mn 10s
Objet : Re: [Red5] Réf.: play a saved Video
you gotta call play by name not path.
Your code wont work when you call play('c:// path/to/file.flv' );
rtmp dont work that way.
study here
http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html#play()
----- Original Message -----
From: "Etienne Bonnefoy" <etiennebon at yahoo.fr>
To: <etiennebon at yahoo.fr>; <red5 at osflash.org>
Sent: Friday, July 17, 2009 3:00 PM
Subject: [Red5] Réf.: play a saved Video
hello,
Do any one have an answer to my question? I can give you détails if
necessary.
Regards,
etienne.
Le jeu. 16 juil 2009 12:25 CEST, Etienne Bonnefoy a écrit :
>Hello,
>
>I'm working with Red5 v0.7 on Windows XP. I'm developping a Flex interface
>from which one can connect to a Red5 Application: MyApplication.
>
>Users can connect to this server, publish in live some video, watch others
>live videos, chat...
>
>But when I try to play a recorded video, I have got no streaming at all.
>I succeed to play a video, with the accurate same code, by creating a
>connection to the Red5 demo: "OflaDemo"...
>
>Lets have a look at my code, maybe someone will be able to enlighten me a
>little bit:
>
>//I open a Pop-Up in which I run my video application:
>VideoSubscriberUser.as
>//I get the existing connection on which the client is
>connected:_connection =
>Red5ServiceLocator.getInstance().getRed5Connection("default");
>==>> If I try to get the connection's URI, it returns me the right one:
>rtpm://localhost/MyApplication
>
>//I create a new container for my video: _outputDeviceoverride
>{
>_outputDevice =
>_outputDeviceWrapper =
>_outputDeviceWrapper.addChild(_outputDevice);
>}
>protectedfunctioncreateChildren():void{super.createChildren();if(!_outputDevice)newVideoOutputDevice();newUIComponent();this.addChild(_outputDeviceWrapper);
>
>//Here is the function called to start the streamingpublic
>_streamOut =
>leStream.bufferTime = 5;functionstartStream(val:String) : void{
>newRed5NetStreamConnector( _connection );varleStream:Red5NetStream =
>_streamOut.getStream();leStream.play(val);
>_outputDevice.attachInputFrom(leStream);
>_outputDevice.width =
>_outputDevice.height = this.unscaledWidth - 10;this.unscaledHeight - 10;}
>
>
>Case KO:
>==>> There, if I call locally this function startStream:
>varlaVideo:VideoSubscriberUser =
>newVideoSubscriberUser(file://C:/Siite/etienne/videos/IronMan.flv);
>I have nothing displayed in my screen.
>Maybe is it due to my wrong path to my video??
>
>Case OK:
>If I create a new connection to: "oflademo", then I can play my video
>correctly:
>1) I connecte my client to my Application: OK. =>
>_connection.URI=rtpm://localhost/MyApplication
>2) I open a new connection to connect to OflaDemo:
>_newConnection.connect("rtmp://localhost/oflaDemo");
>3) I run my video with this connection: _streamOut =
>newRed5NetStreamConnector( _newConnection );
>4) I call my Class with the right path (just IronMan.flv and not all my
>file Path...) to add to my panel:
>varlaVideo:VideoSubscriberUser =
>newVideoSubscriberUser("IronMan.flv");lePanel.addChild(laVideo);
>5) I have my video played correctly...
>
>Could any body help by telling me what is missing in my application
>compared to OflaDemo, please? I can publish video, so My Red5 Server is up
>and running correctly and can perform some broadcasting...The only issue is
>to display a video that is stored in a specific file...
>
>If any detail is necessary, don't hesitate to ask.
>
>Thanks a lot.
>
>Regards,
>Etienne.
>
>or a external video through:varlaVideo:VideoSubscriberUser =
>newVideoSubscriberUser(http://localhost/Siite_Profile/etienne/videos/IronMan.flv);
>
>
>
----------------------------------------------------------------------------
_______________________________________________
Red5 mailing list
Red5 at osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org
----------------------------------------------------------------------------
Internal Virus Database is out-of-date.
Checked by AVG.
Version: 7.5.560 / Virus Database: 270.12.26/2116 - Release Date: 15-05-09 06:16
------------------------------------------------------------------------------
_______________________________________________
Red5 mailing list
Red5 at osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org
------------------------------------------------------------------------------
Internal Virus Database is out-of-date.
Checked by AVG.
Version: 7.5.560 / Virus Database: 270.12.26/2116 - Release Date: 15-05-09 06:16
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/red5_osflash.org/attachments/20090721/00ee8a4e/attachment-0001.html>
More information about the Red5
mailing list