11 Replies Latest reply on May 7, 2010 2:17 PM by kglad

    Video player problem

    kmf54321

      Using an online tutorial, I learned how to put together this actionscript to play video files in a playback component, where an xml file fed the player the titles of the video.

       

      The original code was designed to play the first video in the xml list automatically when the player was loaded. I find this annoying as a consumer, so I did not want this to happen.

       

      I wanted the first video in the list to load and be selected, but I wanted it to play only when someone clicked on the headline. My problem is I can't get the first video to play when the headline is clicked on. It plays only when the play button is pushed. But the other headlines play when they are clicked on.

       

      The online tutorial showed how to get the other headlines to play when clicked on using lList.change = function(), but apparently clicking on the first headline when none have been clicked previously does not constitute "change."

       

      I just finished going through an entire book on actionscript and have come away still not knowing how to fix my problem here. Would anyone on this forum be able to help? Thanks in advance. Joanie

       

       

       

       

      var xml:XML = new XML();

      xml.ignoreWhite = true;

       

      xml.onLoad = function() {

      var nodes = this.firstChild.childNodes;

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

      list.addItem(nodes[i].attributes.desc, nodes[i].attributes.flv);

      }

       

      vid.load(list.getItemAt(0).data);

      list.selectedIndex = 0;

       

      }

      xml.load("videos.xml");

       

      var lList:Object = new Object();

      lList.change = function() {

      vid.play(list.getItemAt(list.selectedIndex).data);

      }

      list.addEventListener("change",lList);

       

        • 1. Re: Video player problem
          kglad Adobe Community Professional & MVP

          that listener should be called.  use the trace() function to confirm.

          • 2. Re: Video player problem
            kmf54321 Level 1

            kglad,

             

            I've been debating whether to keep trying to figure out what you said or just come back and admit defeat.

             

            I know just enough Actionscript to be dangerous.

             

            I'm not sure what you're telling me to do in your reply. I appreciate you trying to help, though.

             

            When you say, "that listener should be called," am I adding more code or changing something? Maybe once I know the answer to that, I will know what to trace.

             

            Thanks.

            • 3. Re: Video player problem
              kglad Adobe Community Professional & MVP

              what's the following show when you click on a list item (and i added a trace() in your onLoad() method to check if you're parsing your xml correctly:

               

              var xml:XML = new XML();

              xml.ignoreWhite = true;

               

              xml.onLoad =  function() {

              var nodes =  this.firstChild.childNodes;

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

              trace( nodes[i].attributes.flv)

              list.addItem(nodes[i].attributes.desc,  nodes[i].attributes.flv);

              }

               

              vid.load(list.getItemAt(0).data);

              list.selectedIndex = 0;

               

              }

              xml.load("videos.xml");

               

              var  lList:Object = new Object();

              lList.change = function() {

              trace((list.getItemAt(list.selectedIndex).data);

              vid.play(list.getItemAt(list.selectedIndex).data);

              }

              list.addEventListener("change",lList);

              • 4. Re: Video player problem
                kmf54321 Level 1

                When I test the flash video with your coding, I get the following in the output panel (those are the two sample videos I have listed in the xml file I'm using for this test):

                 

                videos/party.flv

                videos/Jumper_Dec2_2009_640_veryhigh.flv

                 

                 

                Then, when I click on the first title, I get this in the output panel:

                 

                videos/party.flv

                So, to me, that looks like it's working. And, yet, clicking on that first title does not make the title play. Nothing happens at all. I have to click on the play button on the video player to get that first title to play. If I click on the second title in the list, it plays.
                That's not the worst scenario in the world, but it's confusing to readers that they have to push the play button to play the first video but they can click on the title to play the rest of the videos. There has to be a way to get clicking on the first title to work.
                Joanie

                • 5. Re: Video player problem
                  kglad Adobe Community Professional & MVP

                  use:

                   


                   

                  var xml:XML = new XML();

                  xml.ignoreWhite = true;

                   

                  xml.onLoad =  function() {

                  var nodes =  this.firstChild.childNodes;

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


                  list.addItem(nodes[i].attributes.desc,  nodes[i].attributes.flv);

                  }

                   

                  vid.load(list.getItemAt(0).data);

                  list.selectedIndex = 0;

                   

                  }

                  xml.load("videos.xml");

                   

                  var  lList:Object = new Object();

                  lList.change = function() {

                  vid.contentPath = list.getItemAt(list.selectedIndex).data;

                  vid.play();

                  }

                  list.addEventListener("change",lList);

                  • 6. Re: Video player problem
                    kmf54321 Level 1

                    kglad,

                     

                    you've done it!

                     

                    it works perfectly.

                     

                    i can't thank you enough.

                     

                    joanie

                    • 7. Re: Video player problem
                      kglad Adobe Community Professional & MVP

                      you're welcome.

                       

                      (but, next time, if there's a helpful answer, please mark it.)

                      • 8. Re: Video player problem
                        kmf54321 Level 1

                        I thought I did that at the end. I marked that the question was answered.

                         

                         

                        Should I go back and do something now?

                         

                         

                        I'm sorry. It's only the second time I've visited a forum and the first time I had someone answer me.

                         

                         

                        I am so grateful for your help. I'd be happy to go back and rectify my mistake. What should I do?

                        • 9. Re: Video player problem
                          kglad Adobe Community Professional & MVP

                          there's nothing you can change.

                           

                          but some of us are motivated by the forum point system and you can designate particular answers as

                           

                          1.  helpful

                          2.  solving the problem.

                          • 10. Re: Video player problem
                            kmf54321 Level 1

                            "Helpful" is actually better than "solving?"

                             

                             

                            I would have thought it was the reverse. Good to know.

                            • 11. Re: Video player problem
                              kglad Adobe Community Professional & MVP

                              no, solving is better = 10pts.  helpful =  5 pts.

                               

                              but you can mark a thread as answered and credit noone (like you did).  or you can credit particular answers.