1 Reply Latest reply on Jan 20, 2008 6:21 PM by webby7097

    infoObject conflict or status conflict?

    webby7097 Level 1
      I have a video player that shows a 'buffering video' image while the video is loading. I've added code to have it randomly select a different video to play at the end of the first one, and this causes the video buffer image to always show. If I move the buffer code down, the buffer will work, but the same video will play instead of loading a new one. I think this is a conflict with my ns.onStatus pieces; can someone assist me here?

      Thanks in advance.

      Here is the relevant code:

      // Create the net connection
      var nc:NetConnection = new NetConnection();
      nc.connect(null);

      // Create the net stream
      var ns:NetStream = new NetStream(nc);

      // Attach net stream to the video object
      theVideo.attachVideo(ns);

      // Play random video on load
      filename = ["video1.flv", "video2.flv", "video3.flv", "video4.flv"];
      path = " http://mydomain.com/videos/";
      i = filename.length;
      k = Math.floor(Math.random()*i);

      ns.play(path+filename[k]);

      // Play random video on video end
      ns.onStatus = function(infoObject:Object) {
      if (infoObject.code == "NetStream.Play.Stop" && infoObject.level == "status") {
      ns.seek(0);
      filename =["video1.flv", "video2.flv", "video3.flv", "video4.flv"];
      path = " http://mydomain.com/videos/";
      i = filename.length;
      k = Math.floor(Math.random()*i);
      ns.play(path+filename[k]);
      }
      ns.setBufferTime(10);
      }

      // Code for buffer/scrubber
      ns.setBufferTime(10);

      ns.onStatus = function(info) {
      if (info.code == "NetStream.Buffer.Full") {
      bufferClip._visible = false;
      }
      if (info.code == "NetStream.Buffer.Empty") {
      bufferClip._visible = true;
      }
      if (info.code == "NetStream.Play.Stop") {
      ns.seek(0);
      }
      }
        • 1. Re: infoObject conflict or status conflict?
          webby7097 Level 1
          Fixed by combining all of the onStatus items like this:

          ns.onStatus = function(info) {
          if (info.code == "NetStream.Buffer.Full") {
          bufferClip._visible = false;
          }
          if (info.code == "NetStream.Buffer.Empty") {
          bufferClip._visible = true;
          }
          if (info.code == "NetStream.Play.Stop" && info.level == "status") {
          filename = ["video1.flv", "video2.flv", "video3.flv", "video4.flv"];
          path = " http://mydomain.com/videos/";
          i = filename.length;
          k = Math.floor(Math.random()*i);
          ns.play(path+filename[k]);
          vidTitle.text = va[k];
          }
          }