Skip to main content
Zhil75
Participant
September 9, 2010
Question

playlist xml on FMIS3.5

  • September 9, 2010
  • 1 reply
  • 1421 views

Hello

Looking to make a script on my server FlashMedia who plays my playlist xml loop. The script works for the first reading of the playlist but I do not know how to play it at infinity.
Can you add my script?

Thanks,

Gilles

France

application.allowDebug = true;

//Define events on application start

application.onAppStart = function() {

    trace("Application started.");

    //Define stream name

    this.psuedoStream = Stream.get("clientPlayStream");

    //Define playlist variables

    var xmlPlaylist = new XML();

    xmlPlaylist.ignoreWhite = true;

    var resetPlaylist = true;

    //Create and read playlist file

    fileObj = new File("directtvf.xml");

    fileObj.open("UTF8","read");

 

    //Define events on playlist load

    xmlPlaylist.onLoad = function(val) {

        trace("Playlist loaded.");

     

        //Define video array

        var videos = xmlPlaylist.firstChild.childNodes;

        trace("Playlist contains "+videos.length+" items...");

     

        //Loop through playlist

        for (i = 0; i < videos.length; i++) {

         

            //Define video variables

            var videoTitle = videos.attributes.title;

            var videoURL = videos.firstChild.nodeValue;

            trace((i+1)+": "+videoTitle+" ("+videoURL+")");

         

            //Play video

            if (i == 0) {

                application.psuedoStream.play(videoURL, 0, -1, true);

            }

            else {

                application.psuedoStream.play(videoURL, 0, -1, false);

            }

        }

    }

 

    //Load playlist file

    xmlPlaylist.load(fileObj);

  

}

//Prevent termination of application


application.onAppStop = function() {
    return true;
}
    This topic has been closed for replies.

    1 reply

    September 13, 2010

    Hi,

    Check out my last couple of responses in the thread http://forums.adobe.com/thread/705895 . I think that is very near to what you are trying to achieve. Revert back if you need more help.

    Thanks,

    Abhishek

    Zhil75
    Zhil75Author
    Participant
    September 13, 2010

    Hi,

    Thanks for your help but your code below doesn't work, can you see what's going wrong ?

    Thanks

    Gilles

    application.onAppStart = function () {


         trace("app started");

         clientStream = Stream.get("clientPlayStream");

         clientStream.onPlayStatus = function(info) {

              if(info.code == "NetStream.Play.Complete")

                   formPlaylist("http://viedimage.net/directtvf.xml");

         }

         formPlaylist("http://viedimage.net/directtvf.xml");

    }

    function formPlaylist(xmlname) {

          var my_xml  =  new XML();


         my_xml.load(xmlname);


         my_xml.onLoad = function(resObj) {


         if(resObj) {  //xml loaded successfully


                 //your logic here

                 trace("xml loaded successfully");


                 if (my_xml.firstChild.hasChildNodes()) {

             for (var aNode = my_xml.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {

                 if (aNode.nodeType == 1) {

                     trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);

                     clientStream.play(aNode.firstChild.nodeValue, 0 , 20 , false);

            }

        }

    }


         }

         else

          {

                  ///error message

                   trace("Sample xml failed to load");

         }

    }

    }

    September 13, 2010

    Hi,

    What is the error that you are getting? Is the xml file getting loaded correctly, i.e, is xml.onLoad  trigerring? Since you are accessing it over HTTP make sure both your SSAS and xml file are on same domain.

    However, my point was you can use the same code you posted first. To repeat the loop, you need to form the playlist again after you recieve NetStream.Play.Complete on the Stream object.

    Thanks,

    Abhishek