12 Replies Latest reply on Apr 23, 2011 12:03 PM by adninjastrator

    Video stumper

    Captain825 Level 1

      Hi

       

      I have a Flash 8 Pro site with AS2.  One of the pages is a video page that loads .flv videos externally.  The user can click on a video on the list, click on a "Random" button to let the videos play randomly or click on a "Sequential" button to let them play sequentially.  The first video in the list plays fine but when I click on another video on the list, it doesn't load/play.  The videos are listed in an xml file.  I've tried everything and I can't get it to work so I'm hoping I can find some help out there.  Here is my code.

       

      var xml:XML = new XML();
      stopAllSounds();

      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.play(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);
      count = list.selectedIndex;
      }

      list.addEventListener("change",lList);

      var vidList:Object = new Object();

      var count:Number = 0;

      vidList.complete = function() {
      if(seq.selected) {
        if(count == list.length-1) {
         count = 0;
        }
        else {
         count++;
        }
      }
      else {
        var temp = count;
        while(temp == count) {
        count = Math.floor(Math.random()*list.length);
        }
      }
      vid.play(list.getItemAt(count).data);
      list.selectedIndex = count;
      }

      vid.addEventListener("complete",vidList);

       

       

      Thanks in advance.

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

          use the trace() function to debug your code.

          1 person found this helpful
          • 2. Re: Video stumper
            Captain825 Level 1

            I checked my code and can't find any bugs.  I did some

            experimenting and it looks like the flvplayback component that I am using

            will only play low quality, small videos but won't play high

            quality larger videos.  When I used the small video files, the code and player

            worked fine.

             

            Does the flvplayback component have a file size restriction or is there a setting that I need to adjust?

             

            Thanks

            • 3. Re: Video stumper
              adninjastrator Level 4

              I've never heard of or experience any restrictions of the type you mention...

              When you say "small" and "low quality" what exactly do you mean? What is the bitrate, file size and display dimensions?

              How were the new "high quality" videos created? Are they actually .flv files or are they .f4v files? in other words have they been rendered as HD video? or are these video files that have been transcoded from some other format into .flvs?

              Any and all exact details would be helpful.

              Best wishes,

              Adninjastrator

              • 4. Re: Video stumper
                Captain825 Level 1

                The dimensions of the .flv video that won't play on my flvplayback are 640x360 and is a YouTube video that I downloaded.    The link to the video is http://www.youtube.com/watch?v=ih9SnPtirk8&feature=related

                 

                I don't know if the video was converted to an .flv from some other source and I don't know how to determine bitrate.  I know I'm not much help but maybe with the link above you can get the information you need to help me?

                 

                The same video but with dimensions 400x226 plays fine.

                 

                Thanks

                 

                '

                • 5. Re: Video stumper
                  adninjastrator Level 4

                  Are you saying that if you play that video file in the FLVPlayback component and you set the dimensions of component to 400 x 226 the file plays just fine, but the exact same video file will not play if you change the Playback component to 640 x 360.... the same video file, just different dimensions for the display?

                  Adninjastrator

                  • 6. Re: Video stumper
                    Captain825 Level 1

                    The player's dimensions are currently 440x330.  The problem is when I try loading and playing flvs of different dimensions. A 400 x 226 flv plays fine but a 640 x 360 flv doesn't load or play.  I tried changing the player dimensions to 640x360 and even larger but that didn't work either.  I also tried letting the player auto size but again no good.

                     

                    Any ideas?

                    • 7. Re: Video stumper
                      adninjastrator Level 4

                      The Forum seems a little whacky this morning... I don't see the latest reply that I just posted..

                      So I'll ask again.

                      Is it the exact same video file that you are attempting to display? it works at 400 x 226 but not at 640 x 360?

                      Exact same file, just different dimensions in the FLVPLayback component?

                      Did you actually download the file or are you just using the YouTube URL?

                      If you did actually download the file, how did you do that?

                      Is this the one and only file you are having problems with?

                      Adninjastrator

                      • 8. Re: Video stumper
                        adninjastrator Level 4

                        I have never heard of or seen a problem playing a video because of the changing the player dimensions. There may be something very simple that’s broke but I don’t know what it would be.

                        Have you ever tried NetStream instead of the FLVPlayback?

                        You might want to give that a try.

                        Here is all you need to create a simple video player… it will also trace any metadata contained in the video file (pixel dimensions, bitrate, etc).

                        Start with a new Flash document, set the dimensions large enough to hold whatever size video player you want. Do not use the FLVPlayback component.

                        From up in the Library title pane, way to the far right is a tiny little icon, click on it and a drop down menu will display. Click “New Video”… now a video is in the Library. Drag and drop unto stage and give it an instance name of “video_screen”. Set the desired display dimension right there in the Properties Panel.

                        Create an Actions layer and paste this in:

                         

                        /* Video player created by CI Digital Media for educational purposes */

                         

                        var nc:NetConnection = new NetConnection();

                        nc.connect(null);

                         

                        var ns:NetStream = new NetStream(nc);

                        video_screen.attachVideo(ns);

                        /* Name of your video, with correct path, goes here */

                        ns.play("video1.flv");

                        /* Comment out this pause line for use with auto start or leave pause to start with Play button

                        ns.pause();

                        */

                         

                        rewind_btn.onRelease = function() {

                                    ns.seek(0);

                        }

                         

                        play_btn.onRelease = function() {

                                    ns.pause();

                        }

                         

                        var videoInterval = setInterval(videoStatus,100);

                        var amountLoaded:Number;

                        var duration:Number;

                         

                        // Trace the metadata then remove the last comment tag from code below //

                        ns.onMetaData = function(myMeta) {

                                    for (var i in myMeta) {

                                                trace(i + ":\t" + myMeta[i])

                                    }

                        }

                        /* cut the comment tag from line 35 and paste at end of this line so scrubber will work

                        ns["onMetaData"] = function(obj) {

                                    duration = obj.duration;

                        }

                        */

                         

                        function videoStatus() {

                                    amountLoaded = ns.bytesLoaded / ns.bytesTotal;

                                    loader.loadBar._width = amountLoaded * 160;

                                    loader.scrub._x = ns.time / duration * 160;

                        }

                         

                        var scrubInterval;

                         

                        loader.scrub.onPress = function() {

                                    clearInterval(videoInterval);

                                    scrubInterval = setInterval(scrubit,10);

                                    this.startDrag(false,0,this._y,160,this._y);

                        }

                         

                        loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {

                                    clearInterval(scrubInterval);

                                    videoInterval = setInterval(videoStatus,100);

                                    this.stopDrag();

                        }

                         

                        function scrubit() {

                                    ns.seek(Math.floor((loader.scrub._x/160)*duration));

                        }

                         

                        //-------Sound Controls--------//

                        this.createEmptyMovieClip("sound_mc",this.getNextHighestDepth());

                        sound_mc.attachAudio(ns);

                         

                        var videoSound:Sound = new Sound(sound_mc);

                         

                        mute_btn.onRelease = function() {

                                    if (videoSound.getVolume() > 0) {

                                                videoSound.setVolume(0);                                                    

                                    }

                                    else

                                    {

                                                videoSound.setVolume(100);

                                    }

                        }

                         

                        cidm_btn.onRelease = function() {

                                    getURL("http://www.cidigitalmedia.com/video.html", "_blank");

                        }

                         

                        Save this file in the same folder as your video file. For testing, rename your video file “video1”

                        There is code included for control buttons but you don't need them right now just for testing purposes. Just want to give you a taste of an alternative to the FLVPlayback component.

                        Then control / enter to test the player. It will play the video at whatever dimensions you want and will also trace out any metadata.

                        Go back in the change the display dimensions, test again…

                        If you like working with NetStream, here is a good set of tutorials:

                        http://www.gotoandlearn.com/index.php?currentpage=14

                         

                        Best of luck on your project!

                        Adninjastrator

                        1 person found this helpful
                        • 9. Re: Video stumper
                          Captain825 Level 1

                          Thank you for the netstream, I will

                          go through the tutorials.

                           

                          I tried exactly what you said and, believe it or not, I get the same result.  it plays the videos with the lower dimensions but when I try playing the same video but with higher dimensions, nothing loads.  I am stuck at a road block.

                           

                          Thank you again though for trying to help and for the netstream.

                          • 10. Re: Video stumper
                            adninjastrator Level 4

                            Now I am really perplexed!

                            So you tried the little player code I sent?

                            Did you get any metadata out of the file?

                            Now for my own curiosity I would really like to know why this is happening!

                            Adninjastrator

                            • 11. Re: Video stumper
                              Captain825 Level 1

                              I tried your code and it worked great as long as the video is small in dimension.  I did get the following trace output:

                               

                              height: 480
                              width: 640
                              totalduration: 180.68
                              starttime: 0
                              duration: 180.68

                               

                              but the video wouldn't play.  I made the stage the same size but still no go.

                               

                              As for how I downloaded the YouTube videos, I used Tube Grip to download them

                               

                              I just emailed Lee Brimelow who is the author of the course where I got the code for the flvplayback that I listed in my original post to see if he could help and I'll post the answer if he can figure it out.

                               

                              Adrian

                              • 12. Re: Video stumper
                                adninjastrator Level 4

                                Thanks! I'll keep an eye on this thread.

                                The NetStream code came from Lee's tutorials also by the way.

                                Best wishes,

                                Adninjastrator