質問

I have a 20 minute FLV which streams just fine on server. Client would like to preserve user's locations between sessions so time() is saved to mySQL and passed back in as a FlashVar and is (if set) fed to seek() and to a text field for testing. Thing is the seek() works fine locally but on the server I always get a NetStream.Seek.InvalidTime error no matter what the seek() is set to. Docs are here; it's a dead simple function.

// EDIT Just added keyframes to FLV using http://www.buraks.com/flvmdi/ but this did not resolve issue

src = "videos/LivingProof.flv";

nc = new NetConnection();
nc.connect(null);
nets = new NetStream(nc);
mc_flv.attachVideo(nets);

//Attach your netstream audio to a movielcip: 
snd.attachAudio(nets); 
// create a sound object 
my_snd = new Sound(snd); 
// to adjust the volume 
my_snd.setVolume(50); 
nets.play(src);

if (starttime) {
  var dest:Number = Math.floor(starttime);
  nets.seek(dest);
  this.test.text = 'target time = ' + dest;
}

nets.onStatus = function(infoObject:Object) {
     if( infoObject.level == "status" && infoObject.code == "NetStream.Play.Stop" ) {
        getURL("javascript:setTime('9999999999');", "_self");
        nets.seek(0);
        nets.pause();
        mc_play.gotoAndStop(1);
        trace('onStatus listener fired');
    } else if (infoObject.code == "NetStream.Seek.InvalidTime") { 
        _root.test.text = "NetStream.Seek.InvalidTime";
        nets.seek(infoObject.details); 
    } 
    _root.status.text = infoObject.code;
};

Anyone ever seen this before?

役に立ちましたか?

解決

Try adding an if statement to your onStatus handler to check for the NetStream.Play.Start code and move the seek logic to that:

src = "videos/LivingProof.flv";

nc = new NetConnection();
nc.connect(null);
nets = new NetStream(nc);
mc_flv.attachVideo(nets);

//Attach your netstream audio to a movielcip: 
snd.attachAudio(nets); 
// create a sound object 
my_snd = new Sound(snd); 
// to adjust the volume 
my_snd.setVolume(50); 
nets.play(src);

nets.onStatus = function(infoObject:Object) {
     if( infoObject.level == "status" && infoObject.code == "NetStream.Play.Stop" ) {
        getURL("javascript:setTime('9999999999');", "_self");
        nets.seek(0);
        nets.pause();
        mc_play.gotoAndStop(1);
        trace('onStatus listener fired');
    } else if (infoObject.code == "NetStream.Play.Start) {
       if (starttime) {
          var dest:Number = Math.floor(starttime);
          nets.seek(dest);
          this.test.text = 'target time = ' + dest;
        }
    } else if (infoObject.code == "NetStream.Seek.InvalidTime") { 
        _root.test.text = "NetStream.Seek.InvalidTime";
        nets.seek(infoObject.details); 
    } 
    _root.status.text = infoObject.code;
}; 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top