[Red5] Problems with publisher application

Nathan P. Johansen nathan at npj.com
Thu Feb 14 04:44:50 PST 2008


Hi,

If I recall, the Publisher example is written in Flex, so I'm not sure if
using Ant to compile it is going to produce the desired results.  You'll
probably have to grab a copy of the Flex 2 or Flex 3 SDK and either use
some development tool (like FlashDevelop, Eclipse, or FlexBuilder until
the damn thing expires) or calling "mxmlc" from your command line.

That said, I'd offer a suggestion on the layout of your XML file.  You
might want to add in an identifier for each server entry.  This is what
you have now:

<ServerPresets>
	<ServerPreset>
		<label>moj serwer1</label>
		<host>rtmp://localhost/oflaDemo</host>
		<server>0</server>
		<encode>0</encode>
		<proxy>0</proxy>
	</ServerPreset>
</ServerPresets>


Consider adding a field into your "ServerPreset" definition so that
collection can be better identified (in this example, serverID="1"):

<ServerPresets>
	<ServerPreset serverID="1">
		<label>moj serwer1</label>
		<host>rtmp://localhost/oflaDemo</host>
		<server>0</server>
		<encode>0</encode>
		<proxy>0</proxy>
	</ServerPreset>
</ServerPresets>


So that's one small change, and you should probably account for it by
creating a package and class to handle it instead of using your public
function ServerPreset();  Which you should declare as [Bindable] and
specify that the variables are public and offer a fill function, like so:

_____________

package relative.to.publisher.code
{

[Bindable]
public class ServerPreset
{
    public var serverID : int;
    public var label : String = "";
    public var host : String = "";
    public var server : int = 0;
    public var encode : int = 0;
    public var proxy : int = 0;

    public function ServerPreset()
    {

    }

    public function fill(obj:Object):void
    {
        for (var i:String in obj)
        {
            this[i] = obj[i];
        }
    }

}

}

_____________


Smarter minds than mine might have a better response to what you're trying
to do.  I'm not that familiar with the code for the Publisher application.
I tend to find myself getting confused when I'm working with ActionScript
code and syntax versus Flex syntax and Java syntax ... but that's just
part of the fun to keep up with all of this stuff in your mind.

=)

Nathan



On Thu, 14 Feb 2008, Anton Komarov wrote:

> Hi all.
> I want to modificate publisher application to take streaming servers from an
> xml file instead text input form field
> I find publisher sources and modificate main.as file
> 
> some code below
> I use the AS3.0 style to load XML file and parse it.
> ...
> 
> [Bindable]
> 
> public function myparseXML(){
> 
>     var ap:Array = new Array();
> 
>     var loader:URLLoader = new URLLoader();
>     loader.load(new URLRequest('http://www.glmps.pl/servpres.xml'));
>     loader.addEventListener(Event.COMPLETE, loadXML);
> 
>     function loadXML(e:Event):void{
>     var ap_xml:XML = new XML(e.target.data);
> 
>     function echo(){
>     for each(var e in ap_xml.ServerPreset){
>     var n = new ServerPreset("\"e.label\"","\"e.host\"",e.server,e.encode,e.proxy);
>     ap.push(n);
>     }
>     }
>     }
>     return ap;
> }
> 
> [Bindable]
>         public var serverPresets : Array = [];
> [Bindable]
> ...
> 
> and then in public function Main( nav: Navigation )
> this code
> 
> serverPresets = myparseXML();
> 
> 
> structure of a xml file you can see at www.glmps.pl/servpres.xml
> 
> arguments for function serverPreset is here
>  ......
> public function ServerPreset(    label : String = "",
>                                         host : String = "",
>                                         server : int = 0,
>                                         encode : int = 0,
>                                         proxy : int = 0 )
> .....
> 
> I compile publisher application by the ant. And it compiles but nothing in
> drop down menu is shown :(
> Please help me :)




More information about the Red5 mailing list