Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




UNpause And RESUME My Video Object (netStream)



hey guys....

so i made a netStream video object and 2 buttons (one is play and the other is pause).

the problem i'm having is, when i hit the pause button, it STOPS it, but when i click it again i just want it to resume.

ALSO, when i hit PLAY again, it plays it from the very beginning...NOT from where it got paused.

how can i fix this?
here's my code...


Code:
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.play("http://www.sprokkit.com/clients/deltaco/grandma.mp4");
var metaListener:Object = new Object();
metaListener.onMetaData = onMetaData;
stream_ns.client = metaListener;
var video:Video = new Video();
video.attachNetStream(stream_ns);
addChild(video);

function onMetaData(data:Object):void
{
play_btn.addEventListener(MouseEvent.CLICK, playMovie);
stop_btn.addEventListener(MouseEvent.CLICK, stopMovie);
video.x = (stage.stageWidth - video.width) / 2;
video.y = 25;
}

function playMovie(event:MouseEvent):void
{
stream_ns.play("http://www.sprokkit.com/clients/deltaco/grandma.mp4");
}

function stopMovie(event:MouseEvent):void
{
stream_ns.pause();
}
could someone help?
i'm still fairly new at this =)

thanx


_Chris



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 10-23-2008, 10:51 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

AS2 CS3: Video Player Class W/ NetStream Video Object
is it possible to use the properties of the videoPlayer class with a video object that is not wrapped in a flvplayBack component. I am having trouble using the maintainAspectRatio property with my current video object. Additional question, If you use a flvPlayBack component are you forced to use a skin for the controller or can you use a controller that was built in the swf of the video object?

Video Object And NetStream Help
I am trying to get my flv to play in my video object. So I have been following the Help files and I must not be doing something correct cause nothing is playing.

I added a new video object to my Library and renamed it "my_video" . I then draged it to the stage, set the size properties I needed 320x240 and gave it an instance name of "my_video". Then I attached this code straight from the Help file and changed the file name to play my flv.


PHP Code:



var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(ns); // my_video is a Video object on the Stage
ns.play("VideosIntro.flv"); 




When I test the movie in flash I don't see my video. I also published my flash project and tried playing the swf file but it still doesn't work.

What am I doing wrong?

Flash Video, NetStream Object Error - Help
I've created a flash movie that, among many other things, plays video using the netStream object.

The video player plays quicktime (.mov) files just fine - trouble is, several of my videos arn't playing.

Is anyone else experiencing this issue? I initially thought it had to do with filesize, but I have a small and large file that play just fine, and two others of various size that will not.

The dimensions vary, but the codecs used and everything else about the videos are indentical.

hmm....any suggestions?

Event Listener With Netstream/video Object?
I'm relatively new with actionscript, and I'm having a problem.

I'm building a video player which uses the listbox component and an XML playlist, and originally also used the FLV playback component. I switched out the FLV component for a video object, and now when one video ends, it will no longer begins the next.

Previously an event listener was getting a broadcast from the FLV Component, "complete". Does anyone know a suitable way to replace the the "complete" function, perhaps with an event broadcast from the netstream or video object? I'm not sure, but those ideas came to my mind and I'm wondering how realistic they are. Any help or direction would be greatly appreciated.

Video Paused When Loading Via NetStream Object Within A Function
Hi,

I'm having a problem loading an FLV file via the NetStream object.

The following is on frame 1 of my root timeline:


Code:
loadMovieClip();

function loadMovieClip():Void {
// Create new NetConnection object
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
// Create new streaming object and attach the NetConnection object
var netstream:NetStream = new NetStream(netConn);

_root.bgVideo.attachVideo(netstream);
netstream.setBufferTime(5);
netstream.play("champcrash.flv");

netstream.onStatus = function(infoObject:Object) {
trace("NetStream.onStatus called: ("+getTimer()+" ms)");
for (var prop in infoObject) {
trace(" "+prop+": "+infoObject[prop]);
}
trace("Loaded: " + this.bytesLoaded);
trace("bytesTotal: " + this.bytesTotal);
trace("");
};
};
Nothing too complicated there... its just loading 'champcrash.flv' into the 'bgVideo' object on the stage. My problem is that with the code as above, the video is paused on the first frame, and doesn't progress.

The odd thing is, if I take the contents of the 'loadMovieClip' function, and just place it on the same frame, without any function or function call, then the video will play correctly, without pausing. Code looks like:


Code:
// Create new NetConnection object
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
// Create new streaming object and attach the NetConnection object
var netstream:NetStream = new NetStream(netConn);

_root.bgVideo.attachVideo(netstream);
netstream.setBufferTime(5);
netstream.play("champcrash.flv");

netstream.onStatus = function(infoObject:Object) {
trace("NetStream.onStatus called: ("+getTimer()+" ms)");
for (var prop in infoObject) {
trace(" "+prop+": "+infoObject[prop]);
}
trace("Loaded: " + this.bytesLoaded);
trace("bytesTotal: " + this.bytesTotal);
trace("");
};
The code is EXACTLY the same, except it isn't within a function, yet the latter example plays the video correctly, and the first example doesn't.

This is driving me crazy... any suggestions??

thanks,
Marcus.

NetStream - Resume Connection?
Hi

Is there any way to resume download of flv video when connection is lost for a while (progressive download)?

NetStream Pause, Wait, Resume...
I have an .flv being loaded using NetStream.

I would like the 25 second video to pause for 2 seconds at 4 different intervals, then continue to play.

I would also like a MovieClip to play at certain times during the video.

I tried to get the video to just pause after 4 seconds, I have this so far:

Code:
var myNC:NetConnection = new NetConnection();
myNC.connect(null);
var myNS:NetStream = new NetStream(myNC);

myVideo.attachVideo(myNS);
myNS.play("header.flv");

var time_interval:Number = setInterval(checkTime, 500, myNS);
function checkTime(myNS:NetStream) {
var ns_seconds:Number = myNS.time;
if (ns_seconds>4) {
myNS.pause;
}
}


This code will only get it to pause, then I have to get it to resume after 2 seconds and also trigger an MC to play....

Can somebody help me out here?

I think I'm real close, I'm just missing something in the syntax..

THANKS GUYS!

Mickey

Netstream Won Pause/resume. It Gets Disconnected
im having somethin very odd. when i try to pause a progresive flv it works, but to resume it gets disconnected. and theres no way to get it working.
this is my code
Code:


Code:
package {
import flash.display.Sprite;
import flash.events.*;
import flash.display.MovieClip;
import fl.video.VideoPlayer;
import fl.video.VideoEvent;
import fl.video.MetadataEvent;
import fl.video.VideoProgressEvent;
import fl.video.VideoScaleMode;
import fl.video.VideoState;
import fl.video.NCManager;
import flash.events.NetStatusEvent;

public class myvid extends MovieClip {

private var player:VideoPlayer;

public var src:String;
private var meta:Object;

private var srcw:Number;
private var srch:Number;
private var srcduration:Number;
private var bar:Sprite;
private var posbar:fondo;
private var currentpos:fondo;
private var bloaded:fondo;
private var vc:vcontrol;
private var actionclose:Event=new Event("actionclose");


public function myvid(src:String) {

myMC.dispatcher.addEventListener("actionclose", actioncloseHandler);

player = new VideoPlayer();

//player.idleTimeout=1000000;
player.bufferTime=5;
player.scaleMode=VideoScaleMode.NO_SCALE;
player.setSize(480, 320);
player.x=360;
player.y=7;
addChild(player);
addEventListener(Event.REMOVED,removedHandler);
player.addEventListener(VideoEvent.COMPLETE,vidcompleteHandler);
player.addEventListener(VideoEvent.PLAYHEAD_UPDATE, playingHandler);
player.addEventListener(MetadataEvent.METADATA_RECEIVED, metadataHandler);
player.addEventListener(VideoProgressEvent.PROGRESS, loadingHandler);
player.addEventListener(VideoEvent.STATE_CHANGE, stateHandler);
player.addEventListener(VideoEvent.READY, readyHandler);


controller();
vidload(src);


}
public function vidload(url:String) {

player.load(url);


player.netStream.addEventListener(NetStatusEvent.NET_STATUS,nsHandler);
player.netConnection.addEventListener(NetStatusEvent.NET_STATUS,nsHandler);

}
public function controller() {

bar=new Sprite();

posbar=new fondo(0x333333,0x111111,480,3);
bloaded=new fondo(0x226666,0x111111,480,3,1);
currentpos=new fondo(0xffffff,0x111111,480,3,0.4);
bar.x=365;
bar.y=328;

vc=new vcontrol();

vc.x=360;
vc.y=327;
vc.addEventListener(MouseEvent.CLICK,vcclikHandler);
addChild(bar);
addChild(vc);
bar.addChild(posbar);
bar.addChild(bloaded);
bar.addChild(currentpos);
bar.width=475;
function vcclikHandler(event:MouseEvent):void {

trace(player.state+"||||||||"+event.currentTarget);
/*if (vc.currentFrame==1) {
//vc.gotoAndStop(2);

} else {
//vc.gotoAndStop(1);
player.netStream.pause();
}*/


if (player.state!= "playing") {
trace("try play");
vc.gotoAndStop(1);
player.netStream.pause();
//player.play();

}
if (player.state== "playing") {
trace("try pause");
vc.gotoAndStop(2);
player.netStream.pause();

}


}

}
private function stateHandler(event:VideoEvent):void {

trace("||||||||"+event.state);


}
private function nsHandler(event:NetStatusEvent):void {
trace("_______________"+event.info.code);

}
private function metadataHandler(metadataObj:Object):void {

meta = metadataObj;
srcduration=meta.info.duration;
trace(meta.info.videodatarate);
}
private function loadingHandler(event:VideoProgressEvent):void {
var percent:Number=event.bytesLoaded/event.bytesTotal;

bloaded.width=480*percent;
}
private function readyHandler(event:VideoEvent):void {
trace("ready");
player.play();

}

private function vidcompleteHandler(event:VideoEvent):void {
//player.autoRewind=true;
}
private function playingHandler(event:VideoEvent):void {
currentpos.width=(480/srcduration)*event.playheadTime;
}
function actioncloseHandler(event:Event):void {
trace("close");
parent.removeChild(this);
}
function removedHandler(event:Event):void {
player.close();
addEventListener(Event.REMOVED,removedHandler);
player.removeEventListener(VideoEvent.COMPLETE,vidcompleteHandler);
player.removeEventListener(VideoEvent.PLAYHEAD_UPDATE, playingHandler);
player.removeEventListener(MetadataEvent.METADATA_RECEIVED, metadataHandler);
player.removeEventListener(VideoProgressEvent.PROGRESS, loadingHandler);
player.removeEventListener(VideoEvent.STATE_CHANGE, stateHandler);
player.removeEventListener(VideoEvent.READY, readyHandler);
}
}
}

Resume() For Video Only Working Sometimes
Anyone know why the resume() function only works sometimes on my app. This is running on my local machine. The path I take to get the bug is exactly the same, and sometimes the video decides to resume and other times it doesn't. Any ideas?

Problem With Video Pause & Resume
Hi,

I wonder if someone out there might be able to help me out with an actionscript issue, as I have little clue what I'm doing with it!

I've got a Flash file with a video symbol on the stage with the instance name 'videoPlayer'. I'm controlling video playback using the following script to play the video, check when it finishes, then resume playing the rest of the timeline:stop();

var duration:Number = 0;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachVideo(ns);
ns.play("GuidelinesMovieR24.flv");

ns.onMetaData = function(evt:Object):Void {
duration = evt.duration;
};
ns.onStatus = function(evt:Object):Void {
if (this.time > 0 && this.time >= duration) {
trace("Video complete")
delete this.onStatus;
gotoAndPlay(50);
}
}
I've then also got 2 buttons on the stage for pause and play. The pause button is working fine, with the following script attached to it:on (press) {
ns.pause();
}
The resume play button is where I'm having trouble. I've got the following script attached to it:on (press) {
ns.resume();
}
..and it's doing absolutely nothing. Could someone out there point me in the right direction of getting this to resume playback please?

Thanks in advance,

Dave

Resume Movieclip And Video When Playpause Clicked
Hello,
I have a movieclip that plays along with a video. I can pause the movieclip and video with the following code:

var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object) {
if (my_FLVPlybk2.paused)
page2bslides_mc.stop();
};
my_FLVPlybk2.addEventListener("stateChange", listenerObject);

...but now I just need the movieclip to resume playing at the same point when the user clicks the play/pause button again. Right now the video resumes but the movieclip stays paused. Thanks for any info!

Netstream As A Sound Object?
Can a netstream be attached to a sound object?

I know this is possible in as2; yet, there was no way to grab the spectrum data.

Can it be done is as3? I am pretty sure it can't; thus, another reason I hate as3. Macromedia/Adobe blocked all the features tht would enable you to avoid having to buy a $5000 piece of software that just enables the feature; the flash com server totally bites.

I would love to save locally, and then just parse the sol.

Sound Object From Flv - NetStream
Is this possible?
To extract and get /create a sound object from the audio only of an flv or video?

Any help would be MUCH appreciated. thanks!

NetStream Object Question
Hi,
I'm attempting to control the display of a movie clip during the buffer status and once video playback is completed. (see code below). I want to make the loading message visible while the video buffers, then make it not visible once it starts playing the video, and keep it hidden when the video has stopped playing. But somehow at the end of the video the loading message is visible. I'm guessing it's because the buffer is emptied on end and this is overriding the "NetStream.Play.Stop" property. Any help would be greatly appreciated. THANKS!

My AS code is as follows:

var ns:NetStream = new NetStream(nc);
ns.setBufferTime(10);
ns.onStatus = function(info){
if(info.code == "NetStream.Buffer.Empty"){
control.loadingvideo._visible = true;
}
if(info.code == "NetStream.Buffer.Full"){
control.loadingvideo._visible = false;
}
if(info.code == "NetStream.Play.Stop" ){
control.loadingvideo._visible = false;
}

}

theVideo.attachVideo(ns);

Total Time For A Netstream Object?
I'm making a video player, and I'm having trouble making a seek bar. There is the "time" property of the netstream, but there doesn't seem to be a way to find the total length of the video in seconds, making it difficult to find the fraction of the video played so far. I notice that there's the total size of the video in bytes, but I'm hoping there's an easier way to determine the length of the video (are bit rates variable or fixed for flv files?)

tia

Progressive And NetStream Video
I have a confusion between progressive and netstream flv,
1) For what different purposes they are used?
2) In which out of these two methods the entire file is loaded first before it starts playing?
3) Are these(progressive and netstream) the the property of flv or they are defined in flash?
4) How to convert a video into a progressive or netstream flv(i am able to convert a video into an flv using flv encoder)

Please ********.
Thanks

NetStream Load Video Help
I have made an flv player using Net stream that is in its own swf. What I am trying to do is externally load this flv player into a movie clip and then depending on a users choice of video change the video within the external video player.


in the video player i have set the net stream to play what is in the variable

ActionScript Code:
ns.play(videoP);

So when I load the player into a movie clip i can change the var with a different path to play,

the AS that i am using in the MC is


ActionScript Code:
videoP = "video/mod1_vid2.flv";
trace(videoP);
newvideo_mc.loadMovie("videoPlayerm1.swf");

my problem is the var is changing to the correct file location, confirmed by trace, but is not changing the videoP var in the player

Any ideas completely stuck

NB: am i right in thinking that a variable can be accessable to external and internal swf?

NetStream And Video Metrics
Hi there,

I am trying to figure out if it is possible to record how much of a specific video a user has watched. I have built my player using the netStream class and am streaming flv files into the player.

Basically I now want to upload the video onto my website and have the player send back a marker at 10% increments as the user watches the video so that I can see how popular each video is.

Does anyone have any ideas on this?

Cheers

Jon

Looping NetStream Video
hi! im trying to loop a H.264 video that im loading up into my site.. in AS3 but i cant figure out how to loop it.. please help


ActionScript Code:
var video:Video;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.client = this;

function netStatusHandler(p_evt:NetStatusEvent):void
{
    if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
    {
        trace("The Movie's file structure is invalid");
    }
    else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
    {
        trace("The Movie doesn't contain any supported tracks");
    }
}
stream_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

video = new Video();
video.width = 1000;
video.height = 170;
video.x = -45;
video.y = 0;

addChild(video);
video.attachNetStream(stream_ns);
stream_ns.play("theMovie.mov");

Video And NetStream Probem
I've got 2 problems with new Flash MX 2004 functionality. I've tried to run flv animation file. However:
1. I don't know how to get length (in seconds) of film I'm loading. I can do that if buffer size is greater than file length and ilm will fully load, however I would like to do that earlier
2. I've got a problem with NetStream.bytesLoaded method. It always returns the same value as NetStream.bytesTotal even if buffer is not fully loaded.

Does anybody know how to resolve these problems.
Greetings
Rav

Status Of A Video/NetStream
Is there any way to get the status of either a NetStream or a Video? I need to know 2 things really: when the NetStream is done downloading, and when the Video has completly played it's content. I've tried googling it (extensively), but can't seem to find anything.

BTW: Using progressive download for the video.

Help is greatly appreciated.

Add Scrub-bar On Netstream Video?
I have a video that im playing via a NetStream, is there a way to add a scrub bar (like something a user can drag backwards to rewind)

Thanks

Get NetStream Video Lengh?
I am trying to get the total miliseconds of a NetStream video


I am trying to figure out the position of the playhead in comparison to the total lenght of the video.

I know I can get the position of the play head in seconds i can user NetStream.time but to tell its position in comparison to the total length of the video I need to know the total length of the video.




Can anyone please help out?

Thanks!

Getting Duration From Netstream Or Video
So I'm creating a custom video player. Granted I know I could just skin the components (I am really excited about the runtime skinning), but I started this before cs3 and now just want to get it done. The only problem is I see no way to determine the duration of the movie which makes it impossible to make a scrubber, where is it or am I just missing something I know the client has some functionality but I can't find any doco on it. Any help would be appreciated.

Looping NetStream Video
hi! im trying to loop a H.264 video that im loading up into my site.. in AS3 but i cant figure out how to loop it.. please help


Code:
var video:Video;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.client = this;

function netStatusHandler(p_evt:NetStatusEvent):void
{
if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
{
trace("The Movie's file structure is invalid");
}
else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
{
trace("The Movie doesn't contain any supported tracks");
}
}
stream_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

video = new Video();
video.width = 1000;
video.height = 170;
video.x = -45;
video.y = 0;

addChild(video);
video.attachNetStream(stream_ns);
stream_ns.play("theMovie.mov");

Use Netstream Video From Class
hello - i'm really stumped. I've used flv control many times in flash but i just can't seem to get it working via a class i'm working on;


ActionScript Code:
var xxx:ns1 = new ns1();
xxx.ini();



ActionScript Code:
class ns1 {
    public function ini() {
        var nc:NetConnection = new NetConnection();
        nc.connect(null);
 
        var ns:NetStream = new NetStream(nc);
        ns.play("http://78.136.37.133/uploadedfiles/videomedia/3_the-ruins-011508-qthighwide/3_the-ruins-011508-qthighwide.flv");
 
        var myVideo:Video = new Video();
        myVideo.attachNetStream(ns);
        addChild(myVideo);
    }
}


whereas this works on the flash timeline;


ActionScript Code:
var nc:NetConnection = new NetConnection();
nc.connect(null);
 
var ns:NetStream = new NetStream(nc);
ns.play("http://78.136.37.133/uploadedfiles/videomedia/3_the-ruins-011508-qthighwide/3_the-ruins-011508-qthighwide.flv");
 
var myVideo:Video = new Video();
myVideo.attachNetStream(ns);
addChild(myVideo);


any help much appreciated!

D.

FLV, NetStream And Video Controls
hello there, i hope anyone can find a solve to my problem
i have a movie in flv format. and i use netconnection and netstream commands to dispaly it in my movie from the hard disk.
the problemis that i can't control some behaviors of my FLV movie:

1- i want to make a stop, forward and backward buttons. i already done with the pause button.

2- i want to make a seek bar for my movie

3- i want to display the total time of the movie and the time of the playhead.

4-on running my application i want the movie to be stopped and the user play it with play button.

i hope that anyone can solve my problem, or forward useful links. thnx

[flash8] Issues With Getting The Duration From A NetStream Object
I'm loading a .flv file with the NetStream object within a class. I'm trying to get the duration of the video through the onMetaData event but I can't seem to take that information out of the function (if I try to access the data or trace the value I get undefined).


Code:
import mx.utils.Delegate;
import caurina.transitions.Tweener;

class PresentationSlideshow.VideoPlayer.VideoScaffold extends MovieClip {

private var _stageWidth:Number = Stage.width;
private var _stageHeight:Number = Stage.height;
private var _ncConnection:NetConnection;
private var _nsStream:NetStream;
private var _flv_mc:MovieClip;
private var _audio_sound:Sound;
private var _isPlaying:Boolean = true;
private var _isMuted:Boolean = false;
private var _videoDuration:Number = 0;

public function VideoScaffold(path:String, vWidth:Number, vHeight:Number){
buildScaffold(path, vWidth, vHeight);
_root.movieContainer._alpha = 100; //this needs to be replaced with proper fade in code
loadVideo(path);
}

private function buildScaffold(path:String, vWidth:Number, vHeight:Number){
// Create container for movie
var movieContainer:MovieClip = _root.createEmptyMovieClip("movieContainer", _root.getNextHighestDepth());
// Attach the video objct within the empty movie
movieContainer.attachMovie("theVideo", "videoContainer", this.getNextHighestDepth());
// Set the container so the video is in the exact middle of the screen
movieContainer.videoContainer._width = vWidth;
movieContainer.videoContainer._height = vHeight;
movieContainer._x = (_stageWidth/2) - (vWidth/2);
movieContainer._y = (_stageHeight/2) - (vHeight/2);
movieContainer.attachMovie("videoControls", "videoControls", movieContainer.getNextHighestDepth());
movieContainer.videoControls._x = (vWidth/2)-225;
movieContainer.videoControls._y = vHeight + 40;
// Makes everything invisible
movieContainer._alpha = 0;
}

private function loadVideo(path:String):Void{
// get the video connected properly
_ncConnection = new NetConnection();
_ncConnection.connect(null);
_nsStream = new NetStream(_ncConnection);
_root.movieContainer.videoContainer.vMovie.attachVideo(_nsStream);
_nsStream.play(path);
// Attach the sound from the video to a new movie clip
this.createEmptyMovieClip("flv_mc", this.getNextHighestDepth());
_flv_mc.attachAudio(_nsStream);
var _audio_sound:Sound = new Sound(_flv_mc);

// Get the duration of the video
_nsStream.onMetaData = function(obj:Object) {
_videoDuration = obj.duration;
trace(_videoDuration);
}

// Mute Button code
var _isMuted:Boolean = false
_root.movieContainer.videoControls.volumeButton.onRelease = function(){
trace(_isMuted);
switch (_isMuted) {
case false :
trace("is false");
_audio_sound.setVolume(0);
_isMuted = true;
_root.movieContainer.videoControls.volumeButton.gotoAndStop("muted");
break;
case true :
trace("is true");
_audio_sound.setVolume(100);
_isMuted = false;
_root.movieContainer.videoControls.volumeButton.gotoAndStop("unMuted");
break;
}

}

// Scrubber codde
_root.movieContainer.videoControls.slider.onPress = function(){
this.startDrag(true, 75.5, 19.2, 375.5, 19.2);
trace(_videoDuration);

}
_root.movieContainer.videoControls.slider.onReleaseOutside = _root.movieContainer.videoControls.slider.onRelease = function(){
this.stopDrag();
}

// Button uses the Delegate class to force the button to play in proper scope
_root.movieContainer.videoControls.playPauseButton.onRelease = Delegate.create(this, playPauseEvent);

}
private function playPauseEvent():Void {
switch (_isPlaying) {
case true :
_nsStream.pause();
_isPlaying = false;
_root.movieContainer.videoControls.playPauseButton.gotoAndStop("playState")
break;
case false :
_nsStream.pause();
_isPlaying = true;
_root.movieContainer.videoControls.playPauseButton.gotoAndStop("pauseState")
}
}
}
I'm creating a video scrubber and I need the duration value to make it work. Any ideas?
--thanks

NetStream.seek() Freezes Video
This thing is driving me nuts!

I'm setting up a video class that loads an FLV. It currently loads and plays the video fine. I have a method called 'position' that takes a number between 0 and 1 and translates that into a location to seek to. That almost works perfectly as well. The problem is that, if I seek() to a time that is within approximately the last 10% of the video duration, it freezes. If allowed to play, it plays right through the last 10% with no problem. It only hangs up when seeked to.

Here is the work file so you can see: http://www.indivision.net/box/videotest/
Ignore the scrub bar there as its not hooked up to the video. If you click on position to .5 it works fine. But you will see that it freezes when you position to .9 which seeks to the last 10%.

I've seen other FLV players that don't have this problem so there has to be some kind of work around. I've gone over my code with a fine toothed comb already and can't determine where the error is.

Anyway, I hope I'm not the only person who has had this problem. Any information would be greatly appreciated and/or a link to a simple (free and with source) flv player with a scrub bar that works cleanly would be great.

Opening And Closing Netstream @ End Of Video
I have created a file that plays from a netstream, and I need script to allow the player to recognize when the video is over and then close and reopen the netstream.

Dynamic Flash Video Using Netstream
Most of the examples I've seen online about dynamically loading flash video looks something like this:


Code:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(ASYNC_ERROR, asyncErrorHandler);
ns.play("video.flv");
var vid:Video = new Video();
vid.attachNetStream(ns);
stage.addChild(vid);
While this does work as advertised, I would like to load in like 5 or so separate flv video files as variables, but not play them immediately. Basically, I want the video to play after the user clicks something, but I want the videos to be loaded in the very beginning, so that there is no buffering between when the user clicks the button and when he views it.
Is there a way to do this?

Netstream Seek Stops The Video
hi
i m trying to make a loop at the end of an FLV movie, played by a NetStream object. At a second or so before the end of it, i m doing a "seek" on the stream to some point in the middle of the video. This usually work, and after the "seek" i get a "Notify" event from the NetStream.

From time to time, this fails, and instead of "Notify" i get "Stop", and the movie stops playing. It seems to have something to do with the point i jump FROM (and not TO) - close to the end (0-3 seconds) it happens (not consistently), 3 or more seconds before the end it doesn't.

Is this a bug with NetStream? did any1 see this behavior b4?

Creating Netstream Video Player?
Hi all,

i know there is a tutorial for this at the site gotoandlearn but that is in as 2.0

and was curious if someone knew the as 3 netstream code to play a video,

also would anyone happen to know if it's possible to show the time of a video being played w/ netstream?

thanks in advance

Does NetStream Fix Slow Video Load On CD?
Hi,
I have another post in the FlashMX forum where I'm attempting to fix a problem I'm having with video loading on a CD. Billy T helped me out a lot, but I'm still having a problem where all the video must preload prior to it being visible. This is causing for up to a 1 minute lag between the CD interface opening and the first video playing.

I have 5 videos that are between 1 and 3 minutes in length. They are currently being preloaded in to the first frame so that once they load, all videos will play smoothly. Like I said, it takes up to 1 min. for all videos to load and this is just unacceptable.

I'm curious to know if I were to upgrade to Flash2004 and use NetStream or something else, if this problem will definately be solved. I need to be able to make a darn good case to my managers for them to drop $200 on the upgrade.

Thanks!

Netstream Buffer, Video Streaming
I want to make a "buffering" to my flash video playback, but -

NetStream.bufferLength is starting to decrease towards the end of video file, also I cannot seem to get it to display numbers from 1 to 100 when my bufferTime is set for example, 17 seconds...
Help!


ActionScript Code:
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
my_video.attachVideo(netStream);
netStream.setBufferTime(17);
netStream.play("http://server.com/videofile.flv");
var a:Number = 0;
onEnterFrame = checkBuffer;
function checkBuffer():Void {
    a = Math.floor(netStream.bufferTime/netStream.bufferLength*100);
    if (a<97) {
        status_txt.text = "buffering... "+a+"%";
    } else {
        status_txt.text = "";
    }
}

Sound But No Video With Netstream From Button
I've searched around, and can't seem to find what's wrong here. I'm working a project that has an interface that will have a scroll pane that is dynamically updated. User can click on any of the thumbnails (buttons) in the pane to load a video in a video component.

Right now, I have thumbnails inside a movieclip. They each have the following standard actionscript for loading external flv's. This fashion loads the sound of the external .flv, but not the video into the pane.

I thought this may be because I have masked layers, so I ran a test with a button on the main stage, not in the movieclip, and using the same code it loads the video and sound just fine. I'm working with AS 2.0 and Flash 8, and used the "new video" from the library options menu that is action script controlled... any pointers?









Attach Code

on (release) {
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video.flv");
}

If FLV Video (netStream) Is Loading But Canceled Bug
this is a weird bug that has me stumped.
I am loading the following movies into a placeholder MC on the timeline for 7 pages that have videos. all the netstream code is the same for each video that is loaded.

everything works fine until I press my menu button to load a new page (SWF) with a new video before the current video is done loading. It causes the next video to no appear or auto play (ingnoring the pause toggle).

Note this only also happens for my video FLV files are 1 megabyte in size. My other 100-450KB are fine if canceled early by a new page loading.

Also not there is no problems if the videos are loaded to 100%.

I thought the NAN value may have been a problem but I put a fix in there and didn't solve it.


So here's the code. The same code is used in 6 files as containers to be loaded into the pages that have text and other content.

They are called via the following on the main menu.
stopAllSounds();
_parent.clickMenuSound.start(0, 1);
_root.gotoAndStop("blankpage");
unloadMovie(_root.seanvideoPlaceholder_mc);
unloadMovie(_root.content_mc);
loadMovie("02 expeditions - page.swf", "_root.content_mc");

so in my (ie.) 02 expeditions - page.swf, there is a callout on the timeline to load my (ie.) 02 expeditions - video.swf which would contain the following code, with a pause toggle to play then play when loaded to 80%.

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("sean talking videos/news.flv");
stream_ns.pause();

var loaded_interval:Number = setInterval(checkBytesLoaded, 5, stream_ns);
function checkBytesLoaded(my_ns:NetStream) {

var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
loadPercent_mc.loaded_txt.text = Math.round(pctLoaded*1.25) + "%";
progressBar_mc._yscale = pctLoaded*1.25 ;
pctLoaded = (!isNaN(my_ns.bytesLoaded/my_ns.bytesTotal)) ? Math.ceil((my_ns.bytesLoaded * 100)/my_ns.bytesTotal) : 0 ;
if (pctLoaded >= 80) {
clearInterval(loaded_interval);
loaded_txt.text._alpha = 0;
progressBar_mc.bar_mc._alpha = 0;
gotoAndStop("videoplay");
stream_ns.pause();
}
}
// Create function for NetStream object
stream_ns.onStatus = function(infoObject:Object) {
if (infoObject.code == "NetStream.Play.Stop") {
trace("Video is stopped and done...");
gotoAndPlay("videostopped");
stream_ns.close();
}
}


Is the netstream being reused globally and causing problems?

I'm baffled. I have a beautiful preloader but got this project that must be done monday morning and going to have to resort to some ugly components.


Thanks in advance.
J






























Edited: 04/21/2007 at 04:30:07 PM by jawtab

Video Netstream.buffer.flush
Hi

Got an urgent matter here
When my flv play I suddenly trace

ns status = NetStream.Buffer.Full
ns status = NetStream.Buffer.Empty
ns status = NetStream.Buffer.Flush

When the Flush reaches my video stopped playing while it isn't reached the end.
This happens when I run it locally and online..

What can I do about this?

Tx
Tom

Netstream Video Buffer Residuals
Have several screens where viewers see video. Using netstream, creating a new object on each screen but when I first go into the new screens and start to play the new netstream video, a quick flash of the previous video appears before playing the new one. I'm stumped. I close the previous object on complete event, create a new object on the next screen and still get the flash of residual video. Ideas?

Video Class Vs. FLV Playback Using NetStream
I am trying to load video using NetStream.

I am able to do this by using the Video Class, but is it possible with the FLV Playback? I would like to add a seek bar so people can scroll the video if they want to.

I know the FLV Playback Component has this built in so I would use it BUT I can't load a stream to the FLV Playback, I can only set it's source. This works fine, but it doesn't allow me to unload it, the sound keeps playing, which is why I ended up using the NetStream instead.

So I have 2 questions.
1) Is it possible to load the NetStream to the FLV Playback component?
2) If not, how do I add the seek functionality to my Video Class?

Please help! :(

Choppy Video Playback (NetStream)
Hi All,

Does anyone know what is best practice for buffering video playback? To prevent choppy playback?

Using NetStream etc...

Any help appreciated.

Kind Regards,

Boxing Boom





























Edited: 11/06/2008 at 11:14:24 AM by Boxing Boom

Streaming Video W/netConnection NetStream
i've got a streaming server that i'm trying to connect to play an .flv in my flash movie.

i've done this before on other servers, no problem. for some reason my stream will play if i put my rtmp address in the content path of the flv playback component, but using actionscript with netConnection/netStream produces no results (netConnection works, video doesn't play though).

all i have from the media server folks is something like this:

rtmp://xxx.xxxx.net/ondemand/23245/mm/flvmedia/201/Your_Filename.flv

like i said, this works fine if i paste it into the content path field on .flvplayback component. I want more control, so i'm trying to connect with netStream, etc. like this:


Code:
stop();

nc= new NetConnection();
nc.onStatus=function(infoObject){
trace(infoObject.code);
tracer.text=infoObject.code;
}

nc.connect("rtmp://xxxx.xxxx.net/ondemand/23245/mm/flvmedia/201");
ns = new NetStream(nc);
ns.onStatus=function(infoObject){
trace(infoObject.code);
tracer2.text=infoObject.code;
}

myVid.attachVideo(ns);
ns.setBufferTime(1);
ns.play("highlights.flv");
if i test movie, i get netConnection connect success traced back and netStream traces back play but nothing shows up in my vid object.
the 201 folder is the folder containing the .flvs supposedly. i've been playing around with the full URL trying to see if 'ondemand' is an application name, etc. no results! any help or insight would be great!

[How-to] Adjust Volume In NetStream Video ?
Hi all

I would like to ask, how can I adjust the volume for the video playback ?
here is the code

Code:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
video.attachNetStream(ns);
/**************************
video.volume(0);
**************************/
ns.play("video.flv");
thanks

Simple NetStream, Info But No Video
Hello all --

Trying to get the video to show on the stage.

Here is the FLA


Code:

import classes.NetConnectionExample;
var videoURL:String = "http://192.168.0.52/stream.flv";
var nc:NetConnectionExample = new NetConnectionExample();
nc.ConnectStream(videoURL);
and here is the AS


Code:

package classes {
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;

public class NetConnectionExample extends Sprite {

private function NetStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
trace(event.info.code);
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + event.info.code);
break;
}
}

public function ConnectStream(videoURL) {

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

var stream:NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
stream.client = new CustomClient();
stream.play(videoURL);

var video:Video = new Video();
video.x = 10;
video.y = 10;
video.attachNetStream(stream);
addChild(video);

}
}
}


class CustomClient {

public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}

public function onCuePoint(info:Object):void {
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}

}

I am getting the video MetaData info returned but the video does not show on the stage?

metadata: duration=479.597 width=368 height=246 framerate=29.970029970029966

Any ideas as to what I am doing wrong?

Thank you,
Jon

Closing NetStream Video Problem
Hi everyone,

Does anyone know how to close a netstream video?
I set up this page where I open a new netstream to play video when the button is clicked. The video plays fine. But, when I navigate to another page, the video disappears, but I can still hear it.

What is the script to close the netstream? And where do I put this script? Video page or in the page where I have my navigation links and loader?

Here is my actionscript from the video page:

var myVideo:NetConnection=new NetConnection();
myVideo.connect(null);
var newStream:NetStream= new NetStream(myVideo);
videoHolder.attachNetStream(newStream);
this.play_btn.addEventListener(MouseEvent.CLICK,re sumefunction)
this.play_btn.visible=false
function resumefunction (myevent:MouseEvent):void {
newStream.resume()
}
this.stop_btn.addEventListener(MouseEvent.CLICK,st opfunction)
this.stop_btn.visible=false
function stopfunction (myevent:MouseEvent):void {
newStream.pause()
newStream.seek(0)
}

this.beauty_btn.addEventListener(MouseEvent.CLICK, playBeauty);
function playBeauty (myevent:MouseEvent):void{
newStream.play("videos/beauty.flv")
this.play_btn.visible=true
this.stop_btn.visible=true
}

this.brief_btn.addEventListener(MouseEvent.CLICK, playBrief);
function playBrief (myevent:MouseEvent):void{
newStream.play("videos/brief.flv")
this.play_btn.visible=true
this.stop_btn.visible=true
}
this.christos_btn.addEventListener(MouseEvent.CLIC K, playChristos);
function playChristos (myevent:MouseEvent):void{
newStream.play("videos/christos.flv")
this.play_btn.visible=true
this.stop_btn.visible=true
}
this.into_btn.addEventListener(MouseEvent.CLICK, playComplex);
function playComplex (myevent:MouseEvent):void{
newStream.play("videos/complex.flv")
this.play_btn.visible=true
this.stop_btn.visible=true
}

newStream.addEventListener(AsyncErrorEvent.ASYNC_E RROR,errorhandler)
function errorhandler (myevent:AsyncErrorEvent){//ignore error
}

Fade In Video Using Netstream Class
hiya,

this is probably simple, but i have created a video player using net stream, but as there is no onLoad or similar event, I can't figure out how to have it fade in instead of just popping up.

i would be very grateful for any ideas anyone out there has.

kate

Error 1010 With NetStream & Video
The last line of my code is generating the following error:


Code:
TypeError: Error #1010: A term is undefined and has no properties.
I'm not sure what the problem is.

[code]var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStrem(nc);

var vid:Video = new Video(640,480);

photo.player.addChild(vid);

photo.player.vid.attachNetStream(ns);

ns.play("demo.flv");

Please Help NOOB - AS3 Netstream Video Preloader
Hello, I'm an AS3 nube. I bought a premade AS3 video player and a separate AS3 preloader from FlashDen...and I'm trying to figure out what the #?$^ I'm doing (lol). Just trying to use the preloader to do the preload for the video player.

Basically, the code for the video player is this (sorry so long):

//////////////////////////////////////////////////////////////////////////////////////////////////////
// made by ivands@live.nl //
// //
// If you wanna resize the video holder, resize the object inside: videoPlayerMovieClipholder //
// //
// If you wanna chance the look of the videoPlayer go into the folder: videoPlayerMovieClip //
// //
// The movieclip player_controls_MC must be on rounded pixels. //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////
// Custumizable var //////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

// video path
var videoPath = "CoWare.flv";

// video auto play
var videoAutoPlay = true;

// full size view at start
var fullSizeView = false;

// double click for full size view
var doubleClick = true;

// click the video for play/pause
var oneClick = true;

// view big middle button
var viewBigMiddleButton = true;

// view time tooltip
var viewTooltip = true;

// mouse hide
var mouseHide = true;

// mouse hide after # seconds
var mouseHideTime = 3;

// sound volume at start
var soundVolume = 1.0;

// play/pause on SPACE key
var spaceKey = true;


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

trace("Video path = " + videoPath);
trace("Video autoplay = " + videoAutoPlay);
trace("Full size view at start = " + fullSizeView);
trace("Double click for full size view = " + doubleClick);
trace("Click the video for play/pause = " + oneClick);
trace("View big middle button = " + viewBigMiddleButton);
trace("View time tooltip = " + viewTooltip);
trace("Mouse hide = " + mouseHide);
trace("Mouse hide time = " + mouseHideTime + " sec");
trace("Sound volume at start = " + (soundVolume * 100) + "%");
trace("Play/Pause on SPACE key = " + spaceKey);

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main Action //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Import costum classes ////////////////////////////////////////////////////////////////////////////////////////////////////////

import caurina.transitions.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// video object /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var video:Video = new Video();
holder.addChild(video);

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

var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

function onStatusEvent(stat:Object):void
{
// if video is finished
if(stat.info.code == "NetStream.Play.Stop")
{
if (player_controls_MC.play_stop_MC.currentFrame == 1)
{
ns.togglePause();
player_controls_MC.play_stop_MC.gotoAndStop(2);
play_but_MC.visible = true;
}
ns.seek(0);
ContextItemPlay.caption = "Play Video";
}
}

var meta:Object = new Object();
var duration:Number;
var videoW:Number;
var videoH:Number;
var holderW:Number = holder.width;
var holderH:Number = holder.height;
var FullSizeNUM;

meta.onMetaData = function(meta:Object)
{
duration = meta.duration;

videoW = meta.width;
videoH = meta.height;

if(videoW > holderW || videoH > holderH)
{
video.width = holderW;
video.height = holderH;
videoW = video.width;
videoH = video.height;
}
else
{
video.width = videoW;
video.height = videoH;
}

video.x = (holder.width / 2) - (video.width / 2);
video.y = (holder.height / 2) - (video.height / 2);

if (fullSizeView == true)
{
video.x = 0;
video.y = 0;
video.width = holderW;
video.height = holderH;

FullSizeNUM = false;
ContextItemFullSize.caption = "Video Size Full";
}
else
{
FullSizeNUM = true;
ContextItemFullSize.caption = "Video Size Normal";
}
}

ns.client = meta;
video.attachNetStream(ns);
ns.play(videoPath);

var st:SoundTransform = new SoundTransform();
ns.soundTransform = st;

st.volume = soundVolume;
ns.soundTransform = st;

var videoMask:MovieClip = new MovieClip();
videoMask.graphics.beginFill(0xffffff);
videoMask.graphics.drawRect(0, 0, holder.width, holder.height);
videoMask.graphics.endFill();
videoMask.alpha = 0;
holder.addChild(videoMask);


//////////////////////////////////////////////////////////////////////////////////////////////////////
// RightClick Menu ////////////////////////////////////////////////////////////////////////////////////

var videoContextMenu:ContextMenu = new ContextMenu();
videoContextMenu.hideBuiltInItems();

var ContextItem:ContextMenuItem = new ContextMenuItem("Video Player Controls", true, false);
videoContextMenu.customItems.push(ContextItem);

var ContextItemPlay:ContextMenuItem = new ContextMenuItem("Play Video", true);
videoContextMenu.customItems.push(ContextItemPlay) ;
ContextItemPlay.addEventListener(ContextMenuEvent. MENU_ITEM_SELECT, menuItemDoPlay);

var ContextItemRewind:ContextMenuItem = new ContextMenuItem("Rewind Video");
videoContextMenu.customItems.push(ContextItemRewin d);
ContextItemRewind.addEventListener(ContextMenuEven t.MENU_ITEM_SELECT, menuItemDoRewind);

var ContextItemFullSize:ContextMenuItem = new ContextMenuItem("Show Full Size", true);
videoContextMenu.customItems.push(ContextItemFullS ize);
ContextItemFullSize.addEventListener(ContextMenuEv ent.MENU_ITEM_SELECT, menuItemDoFullSize);

var ContextItemFullscreen:ContextMenuItem = new ContextMenuItem("Show Fullscreen");
videoContextMenu.customItems.push(ContextItemFulls creen);
ContextItemFullscreen.addEventListener(ContextMenu Event.MENU_ITEM_SELECT, menuItemDoFullscreen);

var ContextItemSound:ContextMenuItem = new ContextMenuItem("Sound On");
videoContextMenu.customItems.push(ContextItemSound );
ContextItemSound.addEventListener(ContextMenuEvent .MENU_ITEM_SELECT, menuItemDoSound);

holder.contextMenu = videoContextMenu;
play_but_MC.contextMenu = videoContextMenu;
player_controls_MC.contextMenu = videoContextMenu;

////

var stageContextMenu:ContextMenu = new ContextMenu();
stageContextMenu.hideBuiltInItems();

this.contextMenu = stageContextMenu;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Properties set ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

if(soundVolume == 0)
{
ContextItemSound.caption = "Sound Off";
}

if (videoAutoPlay == false)
{
ns.seek(0);
ns.togglePause();
player_controls_MC.play_stop_MC.gotoAndStop(2);
play_but_MC.visible = true;
}

if (videoAutoPlay == true)
{
ContextItemPlay.caption = "Pause Video";
play_but_MC.visible = false;
player_controls_MC.timeline_MC.track_MC.buttonMode = true;
player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.CLICK, scrubTo);
player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.MOUSE_DOWN, trackDown);
}

if (viewTooltip == false)
{
player_controls_MC.timeline_MC.thumb_mc.visible = false;
}

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

video.smoothing = true;

player_controls_MC.timeline_MC.thumb_mc.alpha = 0;
player_controls_MC.timeline_MC.thumb_mc.mouseEnabl ed = false;

player_controls_MC.fullscreen_MC.buttonMode = true;
player_controls_MC.play_stop_MC.buttonMode = true;
play_but_MC.buttonMode = true;
player_controls_MC.back_MC.buttonMode = true;
player_controls_MC.sound_MC.volScrubber.scrub.butt onMode = true;
player_controls_MC.sound_MC.sound_icon.buttonMode = true;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EventListener's //////////////////////////////////////////////////////////////////////////////////////////////////////////////

stage.addEventListener(Event.ENTER_FRAME, enterFrame);

if (spaceKey == true)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
}

player_controls_MC.fullscreen_MC.addEventListener( MouseEvent.MOUSE_DOWN, goFullScreen);
player_controls_MC.fullscreen_MC.addEventListener( MouseEvent.MOUSE_OVER, OverHandler);
player_controls_MC.fullscreen_MC.addEventListener( MouseEvent.MOUSE_OUT, OutHandler);

player_controls_MC.play_stop_MC.addEventListener(M ouseEvent.CLICK, toggleHandler);
player_controls_MC.play_stop_MC.addEventListener(M ouseEvent.MOUSE_OVER, OverHandler);
player_controls_MC.play_stop_MC.addEventListener(M ouseEvent.MOUSE_OUT, OutHandler);

if (oneClick == true)
{
holder.addEventListener(MouseEvent.CLICK, toggleHandler);
}

if (doubleClick == true)
{
videoMask.doubleClickEnabled = true;
videoMask.addEventListener(MouseEvent.DOUBLE_CLICK , doubleHandler);
}

if(mouseHide == true)
{
holder.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
holder.addEventListener(MouseEvent.MOUSE_MOVE, mouseHandler);
}

play_but_MC.addEventListener(MouseEvent.CLICK, toggleHandler);
play_but_MC.addEventListener(MouseEvent.MOUSE_OVER , OverHandler);
play_but_MC.addEventListener(MouseEvent.MOUSE_OUT, OutHandler);

player_controls_MC.back_MC.addEventListener(MouseE vent.CLICK, rewindHandler);
player_controls_MC.back_MC.addEventListener(MouseE vent.MOUSE_OVER, OverHandler);
player_controls_MC.back_MC.addEventListener(MouseE vent.MOUSE_OUT, OutHandler);

player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.MOUSE_OVER, trackOver);
player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.MOUSE_OUT, trackOut);
stage.addEventListener(MouseEvent.MOUSE_UP, trackUp);

player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.CLICK, mute);
player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.MOUSE_OVER, rollOnSpeaker);
player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.MOUSE_OUT, rollOffSpeaker);

player_controls_MC.sound_MC.volScrubber.scrub.addE ventListener(MouseEvent.MOUSE_DOWN, volDown);
stage.addEventListener(MouseEvent.MOUSE_UP, volUp);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variable /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var play_butX:Number = play_but_MC.x;
var play_butY:Number = play_but_MC.y;

var controlsX:Number = player_controls_MC.x;
var controlsY:Number = player_controls_MC.y;

var holderX:Number = holder.x;
var holderY:Number = holder.y;

var xMin:Number = player_controls_MC.timeline_MC.track_MC.x;
var xMax:Number = player_controls_MC.timeline_MC.track_MC.x + player_controls_MC.timeline_MC.track_MC.width;

var volxMin:Number = player_controls_MC.sound_MC.volScrubber.stack_MC.x ;
var volxMax:Number = player_controls_MC.sound_MC.volScrubber.stack_MC.x + player_controls_MC.sound_MC.volScrubber.stack_MC.w idth - player_controls_MC.sound_MC.volScrubber.scrub.widt h;

var volPercent:Number = 0.7;

var volscrubX:Number = player_controls_MC.sound_MC.volScrubber.scrub.x;

var mouseTimer:Timer = new Timer(1000, mouseHideTime);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// function's ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Play/Stop function ///////////////////////////////////////////////////////////////////////////////////////////////////////////

function toggleHandler(e:MouseEvent):void
{
videoToggleHandler();
Mouse.show();
mouseTimer.reset();
mouseTimer.stop();
}

function videoToggleHandler():void
{
ns.togglePause();
if(player_controls_MC.play_stop_MC.currentFrame == 1)
{
player_controls_MC.play_stop_MC.gotoAndStop(2);
play_but_MC.visible = true;
ContextItemPlay.caption = "Play Video";
}
else
{
player_controls_MC.play_stop_MC.gotoAndStop(1);
play_but_MC.visible = false;
ContextItemPlay.caption = "Pause Video";
}

player_controls_MC.timeline_MC.track_MC.buttonMode = true;
player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.CLICK, scrubTo);
player_controls_MC.timeline_MC.track_MC.addEventLi stener(MouseEvent.MOUSE_DOWN, trackDown);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Double click function ////////////////////////////////////////////////////////////////////////////////////////////////////////

function doubleHandler(e:MouseEvent):void
{
ns.togglePause();

if(player_controls_MC.play_stop_MC.currentFrame == 1)
{
player_controls_MC.play_stop_MC.gotoAndStop(2);
play_but_MC.visible = true;
}
else
{
player_controls_MC.play_stop_MC.gotoAndStop(1);
play_but_MC.visible = false;
}
FullSizeHandler();
}

function FullSizeHandler():void
{
if(FullSizeNUM == true)
{
FullSizeNUM = false;
Tweener.addTween(video, {x:0, y:0, width:holderW, height:holderH, time:0.5});
ContextItemFullSize.caption = "Video Size Full";
}
else
{
FullSizeNUM = true;
Tweener.addTween(video, {xvideo.width / 2) - (videoW / 2), yvideo.height / 2) - (videoH / 2), width:videoW, height:videoH, time:0.5});
ContextItemFullSize.caption = "Video Size Normal";
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Button Over/Out Handler function /////////////////////////////////////////////////////////////////////////////////////////////

function OverHandler(e:MouseEvent):void
{
var obj:Object = e.currentTarget;
Tweener.addTween(obj, {alpha:0.8, time:1});
}

function OutHandler(e:MouseEvent):void
{
var obj:Object = e.currentTarget;
Tweener.addTween(obj, {alpha:1, time:1});
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rewind function //////////////////////////////////////////////////////////////////////////////////////////////////////////////

function rewindHandler(event:MouseEvent):void
{
ns.seek(0);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OnEnterFrame function ////////////////////////////////////////////////////////////////////////////////////////////////////////

function enterFrame(e:Event):void
{
var nowSecs:Number = Math.floor(ns.time);
var totalSecs:Number = Math.round(duration);

player_controls_MC.time_on_MC.text1.text = videoTimeConvert(nowSecs);
player_controls_MC.time_on_MC.text2.text = videoTimeConvert(totalSecs);

var amountPlayed:Number = ns.time / duration;
var amountLoaded:Number = ns.bytesLoaded / ns.bytesTotal;

player_controls_MC.timeline_MC.scrub.x = ns.time / duration * (300 - player_controls_MC.timeline_MC.scrub.width);

player_controls_MC.timeline_MC.loadbar.width = player_controls_MC.timeline_MC.scrub.x + 4;

player_controls_MC.timeline_MC.dlStatus_MC.width = 298.5 * amountLoaded;

if(viewBigMiddleButton == false)
{
play_but_MC.visible = false;
}
testFullscreen();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// tooltip funtions /////////////////////////////////////////////////////////////////////////////////////////////////////////////

function trackOver(e:MouseEvent):void
{
player_controls_MC.timeline_MC.thumb_mc.x = player_controls_MC.timeline_MC.mouseX + 2;
stage.addEventListener(MouseEvent.MOUSE_MOVE, startFollow);
Tweener.addTween(player_controls_MC.timeline_MC.th umb_mc, {alpha:1, time:1});
}

function trackOut(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, startFollow);
Tweener.addTween(player_controls_MC.timeline_MC.th umb_mc, {alpha:0, time:1});
}

function startFollow(e:MouseEvent):void
{
player_controls_MC.timeline_MC.thumb_mc.x = player_controls_MC.timeline_MC.mouseX + 2;
if(player_controls_MC.timeline_MC.thumb_mc.x <= xMin)
{
player_controls_MC.timeline_MC.thumb_mc.x = xMin;
}
if(player_controls_MC.timeline_MC.thumb_mc.x >= xMax)
{
player_controls_MC.timeline_MC.thumb_mc.x = xMax;
}
stage.addEventListener(Event.ENTER_FRAME, getTimeText);
e.updateAfterEvent();
}

function getTimeText(e:Event):void
{
var percentAcross:Number = (player_controls_MC.timeline_MC.thumb_mc.x) / player_controls_MC.timeline_MC.track_MC.width;
player_controls_MC.timeline_MC.thumb_mc.trackTime_ mc.text = videoTimeConvert(duration * percentAcross);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Scrubber of the timeline function ////////////////////////////////////////////////////////////////////////////////////////////

function trackDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, scrubTo);
}

function trackUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, scrubTo);
}

function scrubTo(e:MouseEvent):void
{
var mouseOn = player_controls_MC.timeline_MC.mouseX + 2;
if(player_controls_MC.timeline_MC.track_MC.mouseX < player_controls_MC.timeline_MC.dlStatus_MC.width)
{
var percentAcross:Number = (mouseOn) / player_controls_MC.timeline_MC.track_MC.width;
ns.seek(duration * percentAcross);
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sound mute function //////////////////////////////////////////////////////////////////////////////////////////////////////////

function mute(e:MouseEvent):void
{
soundMute();
}

function soundMute():void
{
if(player_controls_MC.sound_MC.sound_icon.currentF rame == 4 && st.volume == 0)
{
st.volume = volPercent;
ns.soundTransform = st;
player_controls_MC.sound_MC.sound_icon.gotoAndStop (1);
Tweener.addTween(player_controls_MC.sound_MC.volSc rubber.scrub, {x:volscrubX, time:1});
Tweener.addTween(player_controls_MC.sound_MC.volSc rubber.soundbar, {width:volscrubX, time:1});
ContextItemSound.caption = "Sound On";
}
else
{
st.volume = 0;
ns.soundTransform = st;
player_controls_MC.sound_MC.sound_icon.gotoAndStop (4);
Tweener.addTween(player_controls_MC.sound_MC.volSc rubber.scrub, {x:volxMin, time:1});
Tweener.addTween(player_controls_MC.sound_MC.volSc rubber.soundbar, {width:volxMin, time:1});
ContextItemSound.caption = "Sound Off";
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sound button roll On/Off function ////////////////////////////////////////////////////////////////////////////////////////////

function rollOnSpeaker(e:MouseEvent):void
{
Tweener.addTween(player_controls_MC.sound_MC.playe r_skin, {alpha:0.8, time:1});
}

function rollOffSpeaker(e:MouseEvent):void
{
Tweener.addTween(player_controls_MC.sound_MC.playe r_skin, {alpha:1, time:1});
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// volume Scrubber function /////////////////////////////////////////////////////////////////////////////////////////////////////

player_controls_MC.sound_MC.volScrubber.scrub.x = 48 * soundVolume;
player_controls_MC.sound_MC.volScrubber.soundbar.w idth = player_controls_MC.sound_MC.volScrubber.scrub.x - volxMin + 2;

function volDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, volAdjust);
player_controls_MC.sound_MC.sound_icon.removeEvent Listener(MouseEvent.CLICK, mute);
player_controls_MC.sound_MC.sound_icon.removeEvent Listener(MouseEvent.MOUSE_OVER, rollOnSpeaker);
player_controls_MC.sound_MC.sound_icon.removeEvent Listener(MouseEvent.MOUSE_OUT, rollOffSpeaker);
}

function volUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, volAdjust);
player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.CLICK, mute);
player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.MOUSE_OVER, rollOnSpeaker);
player_controls_MC.sound_MC.sound_icon.addEventLis tener(MouseEvent.MOUSE_OUT, rollOffSpeaker);
}

function volAdjust(e:MouseEvent):void
{
player_controls_MC.sound_MC.volScrubber.scrub.x = player_controls_MC.sound_MC.volScrubber.stack_MC.m ouseX + player_controls_MC.sound_MC.volScrubber.stack_MC.x - (player_controls_MC.sound_MC.volScrubber.scrub.wid th / 2);
player_controls_MC.sound_MC.volScrubber.soundbar.w idth = player_controls_MC.sound_MC.volScrubber.scrub.x - volxMin + 2;

if(player_controls_MC.sound_MC.volScrubber.scrub.x <= volxMin)
{
player_controls_MC.sound_MC.volScrubber.scrub.x = volxMin;
player_controls_MC.sound_MC.volScrubber.soundbar.w idth = player_controls_MC.sound_MC.volScrubber.scrub.x - volxMin + 2;
}
if(player_controls_MC.sound_MC.volScrubber.scrub.x >= volxMax)
{
player_controls_MC.sound_MC.volScrubber.scrub.x = volxMax;
player_controls_MC.sound_MC.volScrubber.soundbar.w idth = player_controls_MC.sound_MC.volScrubber.scrub.x - volxMin + 2;
}
volPercent = (player_controls_MC.sound_MC.volScrubber.scrub.x - player_controls_MC.sound_MC.volScrubber.stack_MC.x ) / volxMax;

st.volume = volPercent;
ns.soundTransform = st;

volscrubX = player_controls_MC.sound_MC.volScrubber.scrub.x;

Tweener.pauseTweens(player_controls_MC.sound_MC.vo lScrubber.scrub, "x");
Tweener.pauseTweens(player_controls_MC.sound_MC.vo lScrubber.soundbar, "width");

// sound icon //////////////////////////////
if (st.volume >= 0.8)
{
player_controls_MC.sound_MC.sound_icon.gotoAndStop (1);
}

if (st.volume <= 0.8)
{
player_controls_MC.sound_MC.sound_icon.gotoAndStop (2);
}

if (st.volume <= 0.3)
{
player_controls_MC.sound_MC.sound_icon.gotoAndStop (3);
}

if (st.volume <= 0.1)
{
player_controls_MC.sound_MC.sound_icon.gotoAndStop (4);
}


e.updateAfterEvent();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Hide mouse function //////////////////////////////////////////////////////////////////////////////////////////////////////////

function mouseHandler(e:MouseEvent):void
{
Mouse.show();
mouseTimer.reset();
mouseTimer.start();
mouseTimer.addEventListener(TimerEvent.TIMER_COMPL ETE, completeHandler);
}

function mouseOutHandler(e:MouseEvent):void
{
Mouse.show();
mouseTimer.stop();
}

function completeHandler(e:TimerEvent):void
{
Mouse.hide();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FullScreen function ////////////////////////////////////////////////////////////////////////////////////////////////////

function goFullScreen(e:MouseEvent):void
{
doFullScreen();
}

function doFullScreen():void
{
if (stage.displayState == StageDisplayState.NORMAL) {

stage.displayState = StageDisplayState.FULL_SCREEN;

// POSITION VIDEO GLOBAL ///////////////////////////////
holder.width = stage.stageWidth;
holder.height = stage.stageHeight;

var pointoint = new Point(0,0);
var obj:Object = holder.localToGlobal(point);
holder.x = holder.x - obj.x;
holder.y = holder.y - (obj.y);

// POSITION CONTROL GLOBAL /////////////////////////////
var point2oint = new Point(0,0);
var obj2:Object = player_controls_MC.localToGlobal(point2);
player_controls_MC.x = Math.round((player_controls_MC.x - obj2.x) + (stage.stageWidth / 2 - player_controls_MC.width / 2));
player_controls_MC.y = Math.round((player_controls_MC.y - obj2.y) + (stage.stageHeight - player_controls_MC.height));

// POSITION BIG PLAY BUTTON GLOBAL /////////////////////
var point3oint = new Point(0,0);
var obj3:Object = play_but_MC.localToGlobal(point3);

play_but_MC.x = (holder.width / 2) - (play_but_MC.width / 2);
play_but_MC.y = (holder.height / 2) - (play_but_MC.height / 2);

//////
var point4oint = new Point(0,0);
var obj4:Object = videoMask.localToGlobal(point4);
videoMask.x = holder.x - obj4.x;
videoMask.y = holder.y - (obj4.y);

} else {

stage.displayState = StageDisplayState.NORMAL;
}
}

function setVideoNormalScreen():void {
holder.width = holderW;
holder.height = holderH;
holder.x = holderX;
holder.y = holderY;

player_controls_MC.x = controlsX;
player_controls_MC.y = controlsY;

play_but_MC.x = play_butX;
play_but_MC.y = play_butY;

Tweener.addTween(player_controls_MC.fullscreen_MC, {alpha:1, time:1});
}

stage.addEventListener(FullScreenEvent.FULL_SCREEN ,onFullSc);

function onFullSc(e:FullScreenEvent):void {
if (stage.displayState == "normal" ) {
setVideoNormalScreen();
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Keyboard function ////////////////////////////////////////////////////////////////////////////////////////////////////////////

function keyPressedDown(event:KeyboardEvent):void
{
var key:uint = event.keyCode;
if(key == 32)
{
videoToggleHandler();
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// videoTimeConvert function ////////////////////////////////////////////////////////////////////////////////////////////////////

function videoTimeConvert(myTime):String
{
var tempNum = myTime;
var minutes = Math.floor(tempNum / 60);

var seconds = Math.round(tempNum - (minutes * 60));

if (seconds < 10)
{
seconds = "0" + seconds;
}
if (minutes < 10)
{
minutes = "0" + minutes;
}

var currentTimeConverted = minutes + ":" + seconds;

return currentTimeConverted;
}



// RightClick Handler ////////////////////////////////////////////////////////////////////////////////////
function menuItemDoFullscreen(e:ContextMenuEvent):void
{
doFullScreen();
}

function menuItemDoPlay(e:ContextMenuEvent):void
{
videoToggleHandler();
Mouse.show();
mouseTimer.reset();
mouseTimer.stop();
}

function menuItemDoRewind(e:ContextMenuEvent):void
{
ns.seek(0);
}

function menuItemDoFullSize(e:ContextMenuEvent):void
{
FullSizeHandler();
}

function menuItemDoSound(e:ContextMenuEvent):void
{
soundMute();
}

function testFullscreen():void
{
if (stage.displayState == StageDisplayState.NORMAL)
{
ContextItemFullscreen.caption = "Fullscreen Off";
}
else
{
ContextItemFullscreen.caption = "Fullscreen On";
}
}



The code for the preloader is this:

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

var loaded:Number = new Number();
var total:Number = stage.loaderInfo.bytesTotal;
var percent:Number = new Number();
this.x = this.y = 0;
indicator_strip.x = indicator_strip.y = 0;

percentTXT.text = "";

(root as MovieClip).addEventListener(Event.RESIZE,function( ){
this.x = this.y = 0;
indicator_strip.x = indicator_strip.y = 0;
});

addEventListener(Event.ENTER_FRAME,function(){
if(percent > 99){
indicator_strip.width = stage.stageWidth;
(root as MovieClip).gotoAndStop(2);
}
loaded = stage.loaderInfo.bytesLoaded;

percent += Math.round(((loaded/total)*100 -percent)/2);
percentTXT.text = percent.toString();
indicator_strip.width += (Math.round(stage.stageWidth/100)*Math.round((loaded/total)*100) - indicator_strip.width)/2;
percentSymbol.x = indicator_strip.x + indicator_strip.width -15;
percentTXT.x = indicator_strip.x + indicator_strip.width - 68;
});


So, there we have it...I'm sure there's a way to combine the two somehow or ??? Right now, I have the preloader on the first frame with a 'stop();' command as instructed, then the movieclip that plays the (netstream class) FLV video...

Right now, it "works" but it is not truly doing its preloading, I'm guessing because the code is not tying with the video (.ns?)...only the stage? Hmmm.

Can some kind person please help me??? Many thanks in advance!

Nate the Noob

Flash Video NetConnection, NetStream
I'm using flash 8 and have a function that creates a new NetConnection and NetStream and attaches the NetStream to the video symbol in my move and loads a video, etc..

What I want to know is can I turn that video symbol into an mc button?

What I mean is...i tried doing this.


ActionScript Code:
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
myFLV.onRelease = function() {
    //do something
    trace("test")
};
flvLoader();
 
//FLV loader
function flvLoader() {
    myFLV.attachVideo(stream_ns);
    stream_ns.play("animations/my.flv");
}
stop();

Copyright © 2005-08 www.BigResource.com, All rights reserved