FORUMS: list search recent posts

FLV pause with Netstream

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Will Kelly
FLV pause with Netstream
on Jun 20, 2008 at 5:41:09 am

New to ActionScript 3.0/Flash CS3 and I am trying to create a play back of a remote flv that plays for 10 seconds and then displays a play button for the user to activate the rest of the video.

I have everything working but the pause. I have tried a number of different methods to no avail. I have searched everywhere but can't find a solution for NetStream. I thought about cue points but I want to be able to ad flv from various sources and cue points may not be in place.

There is most likely a simple solution. I would be grateful for any help.

Thanks,

Will


Return to posts index

Sam Mattern
Re: FLV pause with Netstream
on Jul 18, 2008 at 1:10:49 pm

Will,

You should be able to simply detect the 10 second mark and then call:

ns.pause(); //ns is the name of the netstream

It should look something like this:

var timeInt:Number = setInterval( timeFunc , 10 );
function timeFunc():Void{
if( ns.time == 10 ){
ns.pause();
clearInterval( timeInt );
}
}

Hope that helps. Thanks to Lee Brimelow and his Flash Video Basics series of tutorials for shining the light on Netstream!



Return to posts index

Will Kelly
Re: FLV pause with Netstream
on Jul 27, 2008 at 9:08:22 pm

Thanks Sam. It definitely helped. Sorry for the delayed thanks.

My wife had our son 2 weeks early. I have been busy.

All the best,

Will





Return to posts index


Christoph Lueder
Re: FLV pause with Netstream
on Dec 14, 2008 at 4:29:29 pm

Sam,

thanks for this tip.
I am using actionscript 2.0 on a slide presentation and want to stop a .flv 20 after seconds.
the code I am using on the 1st frame is

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
ns.setBufferTime(2);
ns.onStatus = function(info) {
if (info.code == "NetStream.Play.Stop") {
ns.seek(20);
}
};
myVideo.attachVideo(ns);
var intervalIsSet = true;

on the screen I'm using

on (reveal) {
ns.play("mo1_chunk_5.flv");
ns.seek(2);
var timeInt:Number = setInterval(timeFunc, 10);
function timeFunc() {
if (ns.time == 10) {
ns.pause();
clearInterval(timeInt);
}
}
}

on (hide) {
ns.pause();
}


Where did I go wrong??

Christoph



Return to posts index

Sam Mattern
Re: FLV pause with Netstream
on Dec 15, 2008 at 1:03:37 pm

Got it, forgot the most important part, rounding the time:

if (Math.round(ns.time) == 10) {
ns.pause();
clearInterval(timeInt);
}


Also, you should be comparing it against 20, not 10. Try that. If it cuts a little early, maybe you should use Math.floor(ns.time).

-Sam


Return to posts index

Christoph Lueder
Re: FLV pause with Netstream
on Dec 20, 2008 at 1:54:20 am

Sam,
thanks a lot - problem solved, I really appreciate your help

btw, there's another glitch in my slideshow
if I return to the slide the film is supposed to start up again, but now it stays at the endpoint

the code on the first frame is:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(2);
ns.onStatus = function(info) {
if (info.code == "NetStream.Play.Stop") {
ns.seek(2);
playstatus = 1;
trace(playstatus);
}
};
myVideo.attachVideo(ns);
var playstatus;
function timeFunc() {
if ((playstatus == 1) && (Math.round(ns.time) == 10)) {
ns.pause();
playstatus = 0;
trace(playstatus);
clearInterval(timeInt);
}
}

and on the slide:

on (reveal) {
ns.play("RENAISSANCE paris 2054_1_vertigo_1.flv");
ns.seek(2);
playstatus = 1;
trace(playstatus);
var timeInt:Number = setInterval(timeFunc, 20);
}
on (hide) {
if (playstatus == 1) {
ns.pause();
playstatus = 0;
trace(playstatus);
}
}

Strangely, it works with the following code on the first frame:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(2);
ns.onStatus = function(info) {
if (info.code == "NetStream.Play.Stop") {
ns.seek(20);
playstatus = 1;
trace(playstatus);
}
};
myVideo.attachVideo(ns);

var playstatus;

function ending() {
if (playstatus == 1) {
ns.pause();
playstatus = 0;
trace(playstatus);
clearInterval(myInterval);
}
}

and on the slide:

on (reveal) {
ns.play("RENAISSANCE paris 2054_1_vertigo_1.flv");
ns.seek(2);
playstatus = 1;
trace(playstatus);
myInterval = setInterval(ending, 5000);
}

on (hide) {
if (playstatus == 1) {
ns.pause();
playstatus = 0;
trace(playstatus);
}
}

This second method is less precise, so I'd prefer the first one - an ideas on why the film won't restart when going back to the slide?

Thanks
Christoph



Return to posts index


Christoph Lueder
Re: FLV pause with Netstream
on Dec 20, 2008 at 2:36:15 am

the problem is solved by changing line 6 on the slide to:

var timeInt:Number = setInterval(timeFunc, 2000);

cheers
Christoph



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]