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




NetStream Play Issues



video doesnt play if NetConnection and NetStream is instantiated inside function. But when I place them outside the function the video plays fine. Im stumped, anyone know whats going one?Attach Code// DOES NOT WORKfunction playVideo(){trace(typeof _defaultVid);var nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);_vidPlayer.attachVideo(ns);ns.play('video/archive/HAIRBALL_30_001.flv');playBtn.onPress = function ():Void { ns.pause(false); }pauseBtn.onPress = function ():Void { ns.pause(true); }}// THIS WORKS FINEvar nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc);function playVideo(){_vidPlayer.attachVideo(ns);ns.play('video/archive/HAIRBALL_30_001.flv');playBtn.onPress = function ():Void { ns.pause(false); }pauseBtn.onPress = function ():Void { ns.pause(true); }}Edited: 04/28/2007 at 09:30:19 PM by supdun



Adobe > ActionScript 1 and 2
Posted on: 04/28/2007 07:07:23 PM


View Complete Forum Thread with Replies

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

NetStream.Play.Stop/NetStream.Buffer.Flush Called Prematurely
So I've created a custom video interface (based on the one Lee Brimelow created in his Lynda.com tutorials ) that hinges on the NetStream.onStatus events. It uses the Play.Start and Play.Stop to create an onEnterFrame that updates the progress bar/seek functions/timecode/etc.

My problem is that when I connect it to a FVSS/Media Server, the 'NetStream.Play.Stop' and 'NetStream.Buffer.Flush' events are called about 75-80% of the way through the video - yet the video continues to play perfectly until the end of it. This causes some crazyness with my control interface in relation to controling the video.

So far i've tried it on a 3rd party streaming service, and the dev version of Media Server 2. Same error both places. I'm using the simplest code possible (this is the code for the 3rd parth FVSS, hence the extra parameters in nc.connect).

quote:var serverName:String = "server";
var appName:String = "path";
var streamName:String = "filename";

var client_nc:NetConnection = new NetConnection();
client_nc.connect("rtmp://" + serverName + "/" + appName, false, streamName);
var ns:NetStream = new NetStream(client_nc);

ns.onStatus = function(info){
trace(info.code);
}

testVideo.attachVideo(ns);
ns.setBufferTime(2);
ns.play("whatever");

If anyone can tell me why those two events are being fired 75-80% of the video when it has clearly not Stopped Playing or give me any workarounds for dealing with this, I'll make out with you eternally. Or just be very happy.

Any information on this would be great - I've scoured all the searches/forums for any info on this, and haven't found anything.

Many many thanks for your help!
-will-

NetStream Seek() Issues
Hello,
I am working on a custom flv player, and I am running into issues with the seek() method associated with NetStream. I am tracing the NetStream.time property, and it is remaining the same despite using the NetStream.seek(time - 2). Anyone have any ideas on how to make this work? Here is my code:


ActionScript Code:
public function rw() : void
        {   
            stream.seek(stream.time - 2);
        }

note: stream is defined as a NetStream in a seperate function.

FLV Netstream.send() Issues
I have set up a simple web seminar application that broadcasts live and also records the stream for on-demand playback. I can record the audio-only stream and play it back without issues. However, I run in to problems when I try to use the NetStream.send() functionality in the recording. The playback just stops during the playback of the recorded FLV. Everything will work fine and then it just stops and cannot continue (I have to manually seek ahead for the playback to get going again). The farthest we have gotten is 30 minutes into the playback and then it stopped working. Has anyone else experienced this problem?

[Code]
mic.setRate(11);
live_stream.publish("12345", "append");
live_stream.send("changeSlide", "10");

[Details]
FMS 2.0.4
Audio only. No video
11 Khz audio rate

I can record just the audio without using the NetStream.send() and the FLV plays back fine. The issue is when I try to record the send message events with the FLV. Are there any FLV inspectors available that would allow me to view the NetStream.send() messages that are packaged with the FLV?

[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.play()
I am trying to load a preview frame of my videos. Per the documentation I should be able to say something like

ns.play(filename, 30, 0, true);

This should play the first frame of the video 30 seconds in. This does not seem to work does any know how to fix this or why it is not working.

Play 2 Flvs Through Netstream
hey all

trying to play a couple of external flvs through 1 netstream object (ie one finishes, the next plays)

this works fine


ActionScript Code:
// Create a NetConnection object:
var netConn2:NetConnection = new NetConnection();
// Create a local streaming connection:
netConn2.connect(null);
// Create a NetStream object and define an onStatus() function:
var netStream2:NetStream = new NetStream(netConn2);
netStream2.onStatus = function(infoObject) {
  status2.text += "Status (NetStream2)" + newline;
  status2.text += "Level: "+infoObject.level + newline;
  status2.text += "Code: "+infoObject.code + newline;
  if(infoObject.code=="NetStream.Play.Stop"){
trace('yep');
  }
};
// Attach the NetStream video feed to the Video object:
my_video2.attachVideo(netStream2);
// Set the buffer time:
netStream2.setBufferTime(25);
// Being playing the FLV file:
netStream2.play("ed356k6.flv");

the trace happens and everybody is happy. But if I try to make it play the next vid with

ActionScript Code:
if(infoObject.code=="NetStream.Play.Stop"){
   
      netStream2.close();
      my_video2.clear();
netStream2.play("ed156k.flv");
  }

it continually crashes flash, crashes my browser etc...

what am I doing wrong?

Thanks

NetStream.Play.UnpublishNotify
I am facing a strange behavior with the netstream events with an edge server / origin server configuration. When a publisher stops publishing live streams, the subscribers connected through the edge server are not receiving "NetStream.Play.UnpublishNotify" event. But if the clients connect directly to the origin server, the events are received correctly without any delay. While connecting to the edge servers, if the stream is published again after disconnecting, the clients somehow receives the "UnpublishNotify" event at that time followed by the publish event. I am seeing this issue only for the "UnpublishNotify" Event. The publish event is being sent correctly. This behavior is happening only when connecting to the edge servers. Is there any configuration to change this behavior?
(We are using FMS 3)



























Edited: 07/29/2008 at 03:11:11 PM by Hari Chandrasekhar

NetStream.play And URLRequest
The AS3 docs indicate that NetStream.play() should accept a URLRequest object,

NetStream.play(URLRequest object)

However, I am not able to get this to work. It does not throw any exceptions, just dies silently.

doing

NetStream.play("some url.flv")

works.

Netstream Play Issue
Hi everyone ,

i have two streams published by two different clients, if i want to play both the two streams in a third client how can i do that ..any help?

Client 1:

ns_out.publish("Stream1","live");

Client 2:

ns_out.publish("Stream2","live");


Client 3:

Here i want to play both the above streams published...

What code i can use ?

NetStream.play(); Overlapping Itself?
Hi I am using this code:

ActionScript Code:
//Load and Play Video Functionfunction loadVideo(sVideoPath:String):void {    //Clear Screen    video.clear();    //Close NetStream    nsStream.close();    //Play Movie    nsStream.play(sVideoPath);}


To load a new FLV file (this function is run every time a FLV Video Name is clicked in a list).

What is happening is each video loads ok, no problems and plays etc etc... However to test it further I decided to SPAM CLICK just the one link and found that it ultimate broke, that the nsStream.bytestotal even added to itself etc etc. If I then clicked a new FLV Video Name it would break even further, trying to download two FLVs and play them both at once.

How can I fix this? I tried using the Netstream.close(); but that doesn't seem to have helped.

Cheers,
Ryan

Netstream.play URL Parameter
Hi,
I'm currently launching FLVs into a video component using netconnection and netstream. To change the current video, I'm using buttons that update the netsream url via 'ns.play("url")', my question is this: can I pass a variable to the URL parameter of 'ns.play'?
Basically what I'm attempting to do is to specify the URL for each of my FLVs via the instance name of the buttons calling them, rather than attaching code to each button as there will eventually be loads of them.
i.e. say I have three buttons, instance named 'vid1, vid2 and vid3' respectively; and I have 3 videos named 1.flv, 2.flv, 3.flv
I would like to make flash pass the number on the end of the instance name of each button to the URL parameter of ns.play in order that I don't have to attach individual code to loads of buttons.

I have been attempting to use the following code:
//------- SETUP NETSTREAM/CONTROLLER FUNCTIONS/LOADING BAR/SCRUB/TXT -----------

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);

display.attachVideo(stream_ns);
stream_ns.play("http://www.dedicatedmicros.com/ukftp/FLVHUB/testflv.flv");

//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for(i=1;i<6;i++){
   theButton=_root.btnmenu["vid"+i];
   //this variable stores what number button it is
   theButton.thisNum=i;
theButton.onEnterFrame=function() {
   //on release
   _root.btnmenu["vid"+this.thisNum].onRelease = function() {
      //set stream
      stream_ns.play(["http://www.dedicatedmicros.com/ukftp/FLVHUB/"+this.thisNum+".flv"]);
   }
}
}

This is, however, not passing the variable to the URL parameter of .play

Any ideas how this can be achieved or even a better way around it?

For your reference I have uploaded both a test SWF and FLA to the following:
http://www.dedicatedmicros.com/ukftp/FLVHUB/flvtest.html
http://www.dedicatedmicros.com/ukftp/FLVHUB/flvtest.fla

Any tips/advice are much appreciated,

Thanks,
DigiPencil

NetStream.Play.Stop Before The End Of Flv
Hello.
I'm using FMS 3 to stream recorded flv and mp3 files.
I have a problem with NetStream.Play.Stop - I receive this status code before the end of my flv files.
This happens only when I set bufferTime for my NetStream object greater than 0.
It's very important to get when the playback is finished so I can play the next file in my playlist.
Is there any other way to detect the end of playback?

Thanks in advance.

NetStream.Play.StreamNotFound
I'm making a flash video player and I'm finding that it works fine on a local machine but when i upload it to a server i get this netstream "NetStream.Play.StreamNotFound" status even though i know the mymovie.flv is in the directory.

I was wondering if there was something special you would have to do to the server for it to stream videos?

NetStream Play & Pause Button
I have been using the gotoand learn tutorials to make a flv player i am now trying to make a play and pause toggle button for a netstream connection.

I know i have to create a movie clip with the button play and pause buttons in but what actionscript do i need to check if the video is playing
and display required button.

thanks

Netstream.play Using POST Data?
I have been looking for info on this but cannot find any... chances are, it isn't possible. I, like many, have a video player that is connecting to a rather large list of videos. Since I am passing information back to the server at the same time I am requesting a video, I was wondering if it was possible to POST the data instead of appending it to the url (GET)?

Basically, I am trying to send the user id, session id and video id to a file on the server which handles logging the data and requesting the video from another server altogether, since the url string is getting long, I would like to use POST as the data.method. Like I said, I have looked around to see if it was possible, though I haven't found anything, yet.

Does anyone have an idea of how to do this?

NetStream.Play.Complete Still Not Working
Hoped this would ave been fixed in as3 but this event does not always get triggered. Seems to be related to the encode. Anyways I would like to see others approach to this issue.

Currently I have place a condition in the NetStream.Play.Stop event to check if the ns.time is > the duration-1;

[as]
if (ns.time > duration-1){
playing = "complete";
}
[as]

I have noticed this does even work consistantly unless I change it to ns.time > duration-2.

Does anyone else have a different solution? If so please share.

Play FLV Using NetStream, Without Auto-playing?
Hey all, this seems like it should be really easy. Hopefully someone will have a simple solution.

I'm playing a video using a custom FLV playback class, not using a component. Everything is working fine, the video loads, plays, responds to my custom transport controls, etc.

The final option I need to add to my class is to be able to toggle whether the video begins playing automatically or not. I'd like it to begin loading automatically, but not necessarily playing if I don't tell it to. It feels like there should be a method like NetStream.load() that I should be able to use in the connectStream() function instead of NetStream.play(), but I can't find anything in the docs or online.

Here's what I've tried, that kind of works, but introduces another problem. I pass an autoPlay parameter to the class constructor, stori it as an instance variable, and check that value on NetStream.Play.Start. If the value is false, I pause the vid, seek to 0, and reset the instance variable to true so it will play normally when the user starts it.
This seems to work ok, but also seems to mess with my onMetaData handler, causing it not to be called. Here's the relevant portion of my code:


ActionScript Code:
private var _filename   :String;
private var _autoPlay   :Boolean;
private var _connection :NetConnection;
private var _stream  :NetStream;
private var _video    :Video;
private var _transport  :MovieClip;

function VideoPlayer(vidFile:String, autoPlay:Boolean = false) {
    _filename = vidFile;
    _autoPlay = autoPlay;
   
    _connection = new NetConnection();
    _connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler, false, 0, true);
    _connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);
    _connection.connect(null);
}

private function netStatusHandler(event:NetStatusEvent):void {
    switch (event.info.code) {
        case "NetStream.Play.Start":
            trace("_autoPlay: " + _autoPlay);
            if (!_autoPlay) {
                _stream.pause();
               
                // This is the line that causes trouble.
                //_stream.seek(0);
               
                _autoPlay = true;
            }
            break;
        case "NetConnection.Connect.Success":
            connectStream();
            break;
        case "NetStream.Play.StreamNotFound":
            trace("Error: Stream not found - " + _filename);
            break;
    }
}

private function connectStream():void {
    var meta:Object = new Object();
    meta.onMetaData = metaDataHandler;
    _video = new Video(1, 1);
   
    _stream = new NetStream(_connection);
    _stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    _stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorEventHandler);
           
    _stream.client = meta;
   
    _video.attachNetStream(_stream);
    addChild(_video);
   
    _stream.play(_filename);
}
   
private function metaDataHandler(dataObj:Object):void {
    // Resize video
    _video.width = dataObj.width;
    _video.height = dataObj.height;
   
    _transport = new TransportControls(_stream, dataObj);
    _transport.y = dataObj.height + 4;
    addChild(_transport);
   
    // Notify work section that this sample is ready
    dispatchEvent(new Event(Event.INIT));
}


Thanks for any help with this!

NetStream.Play.StreamNotFound Not Working
The fonction NetStream.Play.StreamNotFound whit flash media server is not working please help

main_nc = new NetConnection();
main_nc.connect("rtmp://localhost/video/");
myns = new NetStream(main_nc);

myvideo.deblocking=2;
myvideo.smoothing = true;
myvideo.attachVideo(myns);
myns.onStatus = function(infoObjectbject) {
if (infoObject.code == "NetStream.Play.StreamNotFound") {
_root.gotoAndPlay("bad");
}


};
myns.play("webcam9");
stop();


I want to do if stream fails go to frame bad

Do i ave to create sommething special in my main.asc or my script is not good how to please??

Play And Stop A Netstream Connection
I want to achieve what Youtube does with their videos. They have a giant Play button to start the movie, but users get a glimpse of the video as a preview before the movie starts. How do you stop netstream autoplay and start it from a play button?

Why NetStream.prototype.play Not Wrok
we user flash 8,and flvplayback ,when we use NetStream.prototype.play function like

NetStream.prototype.play = function() {
switch (arguments.length) {
case 1 :
oPlay.call(this, arguments[0]);
break;
case 2 :
oPlay2.call(this, arguments[0], arguments[1]);
break;
case 3 :
oPlay1.call(this, arguments[0], arguments[1], arguments[2]);
break;
}

why flvplayback can't work when play rtmp url.but http url is ok ,anyone who knows this problem ,tell me please,thanks

Reason: NetStream.Play.StreamChanged
Hi, I'm new to Flash Media Server and I'm trying to code a quick capture app llike youtubes'. I have it working when I run it off Flash Media Development Server on my own machine, but when I try to use a streaming service, I get the following output:
reason:NetStream.Play.StreamChanged
clientid:LGegaY0D
details:demo1226424660373
description:Stopped playing demo1226424660373.
code:NetStream.Play.Stop
level:status
when I issue the 'play' command on the NetStream object. I'm not having much luck finding information on the 'StreamChanged' message, has anyone seen this or is this maybe something specific to my host? Thank you in advance for any help.

Simple Problem With NetStream Play ...Please Help Out
Hi All,

i have two streams published by two different clients, if i want to play both the two streams published in a third client how can i do that ..any help?

Client 1:

ns_out.publish("Stream1","live");

Client 2:

ns_out.publish("Stream2","live");


Client 3:

?????????????
?????????????

Here i want to play both the above streams published...

What code should i use here ?...

Please help out .....
Please Help ...it's very urgent....
Thanks,
Saddu.

Netstream - Handling The Progress Of Flv Play
Hi, This might be an minuscule problem, but i really cudn't locate an answer!

I am making an flv player using NetConnection/NetStream concept. As the video plays i'm wanted to show the elapsed time of the flv in a textfield. Now i'm not able to locate the particular event or a method which gets fired continuously till the video is playing.

A similar thing can be achieved by using FLVPlayback component, playheadUpdate event.


Code:
this.c_mcVideoPlayer.addEventListener("playheadUpdate", Delegate.create(this, onPlayheadUpdate));

function onPlayheadUpdate(evt:Object)
{
//do the task.
}
How can i do the same using NetStream ?

Simple Question About Netstream.Play
Hi All,

I have a doubt in using the Netstream.Play. Please explain me how it works.

My Doubt is :

In all clients am playing a stream using the following code :

ns.play("firststream",-1);

The above one works fine.

Now i want to play a second stream, what should i do?

If i give the following codes what will happen?

ns.play("secondstream",-1); is this the correct way?

or should i first stop the stream using ns.stop() and play the second stream using ns.play("secondstream",-1);

or should i use another netstream like ns2.play("secondstream",-1);

My expectation is when one stream is playing i want to stop the previous one which is already playing and start playing a new one, please put me into the correct way, i coudlnt explore how the netstream.play works, someone of you please advice me on how this works.

Thnaks,
Saddu.

Probs With XML & NetStream.Play.Stop
I'M REPOSTING THIS POST B/C I DIDN'T KNOW HOW TO DELETE THE PREVIOUS ONE AND I JUST TOOK THE XML TUTORIALS. (HELP ON DELETING?)

Hey guys, this is an awesome forum and awesome tutorial. I am new to Actionscript- I went to school for designing and ended up with a job programming Flash.

Anyways, I've made a mutt of code using different tutorials based here on GotoAndLearn. I'm making a tutorial that will play flvs called from an XML file. The flvs change when an flv is done playing or the next or previous button is hit.

That said here is the problem: The if statement associated with NetStream.Play.Stop does not work. It won't advance to the next video in the array. Thanks in advance for help.

Here is my code:
Code:

stop();

var tutorial:XML = new XML();
tutorial.ignoreWhite = true;
var videos:Array = new Array();
var chapters:Array = new Array();
var chNum:Array = new Array();
var i:Number;

tutorial.onLoad = function () {
   var loader:Array = this.firstChild.childNodes;
   for(x=0; x<loader.length; x++) {
      trace(x);
      videos.push(loader[x].attributes.url);
      chapters.push(loader[x].attributes.title);
      chNum.push(loader[x].attributes.number);
   }
   
   i = 0;
   ns.play(videos[i]);
   chapterTitle.text = chapters[i];
   chapterNumber.text = chNum[i];
   
}

// This code is the only thing that needs to change in this FLA it manages the XML file
tutorial.load ("tutorial1.xml");
// Do not change anything after this

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

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.setBufferTime(10);

ns.onStatus = function (info) {
      if(info.code == "NetStream.Buffer.Full") {
         introClip._visible = false;
      }
      if(info.code == "NetStream.Buffer.Empty") {
         introClip._visible = true;
      }
      if(info.code == "NetStream.Play.Stop"){
         i++;
         ns.play(videos[i]);
         chapterTitle.text = chapters[i];
         chapterNumber.text = chNum[i];
      }
   }


var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;

this.createEmptyMovieClip("vFrame", this.getNextHighestDepth());
vFrame.onEnterFrame = videoStatus;

ns["onMetaData"] = function (obj) {
   duration = obj.duration;
};

function videoStatus() {
   amountLoaded = ns.bytesLoaded/ns.bytesTotal;
   progressBar.loadbar._width = amountLoaded*377;
   progressBar.purpleBar._width = ns.time/duration*377;
   progressBar.scrub._x = ns.time/duration*377;
}

progressBar.scrub.onPress = function() {
   clearInterval(videoInterval);
   vFrame.onEnterFrame = scrubit;
   this.startDrag(false, 0, this._y, 377, this._y);
};

progressBar.scrub.onRelease = progressBar.scrub.onReleaseOutside=function () {
   vFrame.onEnterFrame = videoStatus;
   this.stopDrag();
};

function scrubit() {
   ns.seek(Math.floor((progressBar.scrub._x/377)*duration));
}

pauseBTN.onRelease = function() {
   ns.pause();
   pauseBTN._visible = false;
   playBTN._visible = true;
};
playBTN.onRelease = function() {
   ns.pause();
   playBTN._visible = false;
   pauseBTN._visible = true;
};

prevBTN.onRelease = function() {
   if (i > 0) {
      i = i-1;
      ns.play(videos[i]);
      chapterTitle.text = chapters[i];
      chapterNumber.text = chNum[i];
   }
};

nextBTN.onRelease = function() {
   if (i < videos.length-1){
      i = i+1;
      ns.play(videos[i]);
      chapterTitle.text = chapters[i];
      chapterNumber.text = chNum[i];
   }
};

this.onEnterFrame = function() {
   cfText2.text = ns.time;
}

and my XML file

Code:

<?xml version = "1.0" encoding = "ISO-8859-13"?>

<videos>
<video url="MarketOverview.flv" title = "Market Overview" number= "One" />
<video url="NewsandCommentary.flv" title = "News and Commentary" number= "Two" />
<video url="AnalystViews.flv" title = "Analyst Views" number= "Three" />
<video url="SectorsIndustry.flv" title = "Sectors & Industry" number= "Four" />
<video url="Economy.flv" title="Economy" number= "Five" />
<video url="Calendar.flv" title = "Calendar" number= "Six" />
</videos>

Pass Variable To Netstream.play URL Parameter
Hi,
I'm currently launching FLVs into a video component using netconnection and netstream. To change the current video, I'm using buttons that update the netsream url via 'ns.play("url")', my question is this: can I pass a variable to the URL parameter of 'ns.play'?
Basically what I'm attempting to do is to specify the URL for each of my FLVs via the instance name of the buttons calling them, rather than attaching code to each button as there will eventually be loads of them.
i.e. say I have three buttons, instance named 'vid1, vid2 and vid3' respectively; and I have 3 videos named 1.flv, 2.flv, 3.flv
I would like to make flash pass the number on the end of the instance name of each button to the URL parameter of ns.play in order that I don't have to attach individual code to loads of buttons.

I have been attempting to use the following code:
//------- SETUP NETSTREAM/CONTROLLER FUNCTIONS/LOADING BAR/SCRUB/TXT -----------

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);

display.attachVideo(stream_ns);
stream_ns.play("http://www.dedicatedmicros.com/ukftp/FLVHUB/testflv.flv");

//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for(i=1;i<6;i++){
theButton=_root.btnmenu["vid"+i];
//this variable stores what number button it is
theButton.thisNum=i;
theButton.onEnterFrame=function() {
//on release
_root.btnmenu["vid"+this.thisNum].onRelease = function() {
//set stream
stream_ns.play(["http://www.dedicatedmicros.com/ukftp/FLVHUB/"+this.thisNum+".flv"]);
}
}
}

This is, however, not passing the variable to the URL parameter of .play

Any ideas how this can be achieved or even a better way around it?

For your reference I have uploaded both a test SWF and FLA to the following:
http://www.dedicatedmicros.com/ukftp...B/flvtest.html
http://www.dedicatedmicros.com/ukftp/FLVHUB/flvtest.fla

Any tips/advice are much appreciated,

Thanks,
DigiPencil

Netstream Play() Method Start Parameter
Anyone know what the other parameters (like Start) are for in the netstream play() method?

play( filepath:String, Start: Number, Len:Number... )

http://livedocs.macromedia.com/fms/2...=00000588.html

Play Netstream Oh But Wait Then REVERSE/REWIND It..
Anyone know how to rewind playback of a netstream video file?

say i am at seek(12390)... and I want it to just go backwards from there to say seek(0). I couldn't seem to find anything on it in the class help docs.

NetStream.Play.Stop Is Called Too Early
Hi there,

i have a video that is streamed over a FMS3. Everything works fine, the only problem is, that NetStream.Play.Stop is fired when the buffer reaches the end of the timeline. I want to fire the event after the video is played until the end.

Has someone a solutions for this problem?

Best Tobi

Detecting End Of Video: NetStream.Play.Stop
I'm losing my mind. All I want to do is goTo a frame number when the video has done playing. GRRR! Hours and hours wasted! I need help! I'm an AS3 noob! Darn N00bs!

Attached is the code.










Attach Code

import caurina.transitions.*;

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

var stream:NetStream = new NetStream(conn);
stream.play("http://www.zipperfish.com/movies/trailers/push.flv");
var metaListener:Object = new Object();
metaListener.onMetaData = theMeta;
stream.client = metaListener;

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

var video:Video = new Video();
video.attachNetStream(stream);
video.width=800;
video.height=340;
video.x=0;
video.y = 0;
video_mc.addChild(video);

Flv Netstream Wait Till 30% Loaded Then Play
Hey this is basically how I have created a media window.
I want the first flv file to load and play. This works fine but What I would like to mash into the equation is a detector for the bytesloaded and if it has loaded say 30% then start playing.
It is a temporary pause the logic of the function is fine but my methods are not. If you know what i mean.

This is the pob: videoLoad_then_play();


Code:

var loaderInterval = setInterval(videoLoadStatus,100);
var loaderAmount:Number;
function videoLoadStatus(){
loaderAmount = net_stream.bytesLoaded / net_stream.bytesTotal;
loader.loadbar._width = loaderAmount * loadbar_Width;
loader.scrub._x = net_stream.time / duration * loadbar_Width;
videoLoad_then_play();
}

function videoLoad_then_play(){
if(loader.loadbar._width >= (loadbar_Width/5)){
net_stream.pause();}
delete videoLoader_then_play();
}
Is there a beter way to do this. The delete and the interval dont seem to be in patnership.

NetStream.play() Playing After Full Buffering
The problem is that FLV movie starts playing after full preloading not streaming.
I am passing FLV with PHP script readfile() method.
Can anybody tell me why my player does not start immediately?

Here is the PLAY part of the code

Code:
if (mc_play_pause.currentFrame == 1)
{
loader.load(new URLRequest(file));
mc_play_pause.addEventListener(Event.ENTER_FRAME, playHeadMove);
btn_volume.addEventListener(MouseEvent.MOUSE_DOWN, startDragVolume);
}
if (isplaying == false && ispaused == false)
{
isplaying = true;
ispaused = false;
ns.bufferTime = 5;
ns.play(file);
mc_play_pause.gotoAndStop(10);
} else if (ispaused == true && isplaying == false)
{
isplaying = true;
ispaused = false;
ns.resume();
trace("Resumed from: " + ns.time.toString());
mc_play_pause.gotoAndStop(10);
} else if (isplaying == true && ispaused == false)
{
isplaying = false;
ispaused = true;
trace("Paused at: " + ns.time.toString());
ns.pause();
mc_play_pause.gotoAndStop(2);
}

Getting NetStream.Play.FileStructureInvalid When Trying To Stream Local MP3
PHP Code:



var connection:NetConnection;var stream:NetStream;var streamURL:String;            function loadStream(url:String):void {    streamURL = url;    connection = new NetConnection();    connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);    connection.connect(null);}function netStatusHandler(event:NetStatusEvent):void {    trace(event.info.code);    switch (event.info.code) {        case "NetConnection.Connect.Success":            connectStream();            break;        case "NetStream.Play.StreamNotFound":            trace("Stream not found: " + streamURL);            break;    }}function connectStream():void {    trace("try to play");    stream = new NetStream(connection);    stream.client = this;    stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);    stream.play(streamURL);}loadStream("testsong.mp3") 




Anyone know anything about this?

Reading A Directory Above Within A Movie Using NetStream.play(url);...
So I have the following:

netStream.play(url);


"url" is externally being passed into it, from the markup (object / parm element). When this gets passed, the movie mistakingly processes the wrong folder because "url" is being read from the folder that the movie resides in. Using something like "../" to go back one directory seems to be ineffective.

How can I make it happen using ActionScript?

NetStream.Buffer.Full > Go To Video But Don't Play
Hi im new here, great site & tutorials.
I have followed all of the Video Basics. its works great.
But i have a question:

After the buffer is loaded its going to play the movie.
But i want after the buffer is loaded that he don't plays the movie but stops and gives you the opportunity to click on a "Play movie" button, wich im going to create myself ofcourse.

Does anybody knows the code to make the video stop after the buffer is full and only play the movie after you hit a button?

I'm still trying myself to get it works but i haven't succeed yet, it would be great if anybody can help me,

thanks,

chris

[MX04] NetStream.Play.Stop & Flash Crashes
Hi,

I've developped a small flash webpage in order to have my showreel online. I need to stream some flv, so I'm using a NetStream object (see code below).

The problem is that Flash crashes when I test the end of the flv in my onStatus function . It takes a long time to trace "NetStream.Play.Stop" onto the output window, then it crashes immediately.
It's even more bizarre as it works fine when I test it in debug mode.

Any help would be very welcome as this drives me crazy and I need to have this online by the end of the weekend.
Many Thanks !!
Kz.



Code:
var connection:NetConnection = null;
var stream:NetStream = null;

function initStream()
{
this.connection = new NetConnection();
this.connection.connect(null);
this.stream = new NetStream(this.connection);
this.stream.setBufferTime(5);

stream.onStatus = function(infoObject:Object)
{
trace(infoObject.code);

if(infoObject.code == "NetStream.Play.Stop")
{
stream.close();
_level0.videoStopped();
}
}

this.embeddedVideo.attachVideo(this.stream);
}

function startVideo(url:String, widescreen:Boolean)
{
this.embeddedVideo._visible = false;
_level0.resizeTransportBar(widescreen);
if(widescreen)
{
this.embeddedVideo._width = 400;
this.embeddedVideo._x = 0;
}
else
{
this.embeddedVideo._width = 300;
this.embeddedVideo._x = 50;
}

this.bufferingMC.go();
this._visible = true;

this.stream.close();
this.stream.play(url);
this.stream.onMetaData = function(infoObject:Object)
{
_level0.setLoadingBar(this, Number(infoObject.duration));
}

var bufferInterval:Number = setInterval(checkBufferTime, 10, this.stream);
function checkBufferTime(ns:NetStream):Void
{
var bufferPct:Number = Math.min(Math.round(ns.bufferLength/ns.bufferTime*100), 100);
if(bufferPct > 90)
{
bufferingMC.gotoAndStop("stop");
embeddedVideo._visible = true;
clearInterval(bufferInterval);
}
}
}

Using "NetStream" Class To Play A Movie When The Previous One Has Ended.
I´m pretty new at this and could really use some help
I want to trigger a new video "video2.flv" when the first one finishes, and I´m sooo close. The onStatus handler (it´s a handler...right?) works and traces "finished" when the first video reaches the end. Then I try to play the second video and it completely freezes. I´m using netStream.play("videos/video2.flv"); which makes sense to me, but it´s obviously not right...




Code:
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
Smartvideo.attachVideo(netStream);
netStream.setBufferTime(5);
netStream.play("videos/video1.flv");

netStream.onStatus = function (vInfo) {
trace(vInfo.code)
if (vInfo.code == "NetStream.Play.Stop") {
trace("finished")
netStream.play("videos/video2.flv");

}
}


stop();

Using "NetStream" Class To Play A Movie When The Previous One Has Ended.
I´m pretty new at this and could really use some help
I want to trigger a new video "video2.flv" when the first one finishes, and I´m sooo close. The onStatus handler (it´s a handler...right?) works and traces "finished" when the first video reaches the end. Then I try to play the second video and it completely freezes. I´m using netStream.play("videos/video2.flv"); which makes sense to me, but it´s obviously not right...


Code:

var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
Smartvideo.attachVideo(netStream);
netStream.setBufferTime(5);
netStream.play("videos/video1.flv");

netStream.onStatus = function (vInfo) {
trace(vInfo.code)
if (vInfo.code == "NetStream.Play.Stop") {
trace("finished")
netStream.play("videos/video2.flv");

}
}


stop();

FLV InfoObject Not Always Sending "NetStream.Play.Stop" At End?
Hello friends,

How do I know when a video has stoped, using AS2 code, if I don't get the right event sent???

With some FLV videos I get:

NetStream.Play.Start
NetStream.Buffer.Full
NetStream.Buffer.Flush
NetStream.Buffer.Empty
NetStream.Buffer.Flush
[and then it 'stops' but never sends the stop event]

And with other FLV's I get:

NetStream.Play.Start
NetStream.Buffer.Full
NetStream.Buffer.Empty
NetStream.Buffer.Full
NetStream.Buffer.Flush
NetStream.Play.Stop
NetStream.Buffer.Empty
NetStream.Buffer.Flush

This is REALLY annoying! Anyone else ever get this issue or knwo how to solve it??? thanks!!!!

seb.

Problems With "NetStream.Play.Stop"
Hello Flashgurus!

I was (successfully) going through the Video-Basics-Tutorials. Then I wanted to do some changes...

I created a .swf File (very small filesize) just containing a button and some text. My intention: the user clicks on the button and then the .swf with the player will be loaded.

This is the code I used on the button in this .swf file:

Code:

on(release) {
   loadMovie("movie1.swf", this);
}


This works perfect. As soon as the user clicks on the button, the movie1.swf is loaded, the buffering-sequence appears and soon later the movie starts playing.

After the movie is finished I want it to return to the initial .swf. To accomplish that I used the following code (as shown in the tutorial - I just changed the NetStream.Play.Stop behaviour):

Code:

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);
      loadMovie("flvplayer.swf", this);
      }
}


But that does not work. The movie starts again. And again. And again... I tried everything form adding a stop(); to removing the ns.seek(0);... no success.

Has anybody an idea how to solve that problem??? (I am really just starting Action Script... Maybe I missed a simple rule?)

Many thanks in advance!

Sugus

Play And Pause Issues
Hi,
I am having some trouble with adding Play and Pause buttons to my flash movie. Basically this movie consists of music, speech and a table of contents which is navigational for the different subunits. Currently the users will have to watch the whole movie without being able to pause it. I cannot seem to get the play and pause scripts to work. I have tried the 2 different scripts;
1. Pause Script:
on (release) {
gotoAndStop(2);
_parent.stop();

1. Play Script
on (release) {
gotoAndStop(1);
_parent.play();


2. Pause Script
on (press) {
stop();
}
2. Play Scritp
on (press) {
play();
}



Attached is an image of my timeline that might be useful when understanding what I am dealing with. Within the red box is my button area.
[/font]

[F8] Play Button And Lip Sync Issues -- Please Help
I'm on the final stages of making my little cartoon but I'm facing two issues.

1) I'm creating the Play button. The button works and I've put the stop(); command on the first frame of all my layers (that's what you do, right?), but when I preview the movie, the Mouth layer of my animation plays and plays really fast. When I press my play button, the animation starts no problem and the mouth syncs up how I want. The problem is before I press the play button, it's like the Mouth layer is going crazy.

2) I added some more content to my project recently. When I preview everything in the workspace it's just how I want it, but when I preview it in the player, the new content is out of sync. Again, it's a problem with the mouth and the audio. I don't get this at all, as it only goes out of sync with the new content.

Any help would be MUCH appreciated.

"NetStream.Play.Stop"
Is "NetStream.Play.Stop" really reliable. It seems that sometimes I play a flv on my site and it never calls the NetStream.Play.Stop even when the movie stops. Is there any 'solid' way to know you movie has completely played.

Thanks,
Josh

Streaming Movie Issues -Not Able To Click Play More Than Once
Let me just preface this question...I just got Flash 8 Pro here at work and I have Never worked with flash before...
With that being said I have worked as a graphic designer for 10 years and in my job I now must start doing more interactive advertising banners.
I am trying to have a progressive download of a .FLV from our servers and It works. BUT I am using the pre-built skins and I can play the movie once but when it's done I have to reload the page to be able to play the movie again.
I would like users to be able to click the play button after they have seen it once and view the clip again.
I have tried setting the autorewind to "true" and this does not achive this function.
What are my options and what am I missing?

tTis program is very deep!

Thank you in advance

Not Receiving OnStatus Event After "NetStream.Play.Stop" Event Is Received
Hi,

I am trying to play flv file in swf, using NetStream. I have registered for onStatus event. I receive all the events till I receive "NetStream.Buffer.Flush" & "NetStream.Play.Stop" in same order at the end of the video... After that when I drag the video using seek and play the video again, I don't receive any events in registered call back onStatus function...

I need to make status text updates on video, even after video has fully downloaded and stopped & if replayed... Any idea what is going on and what I need to do different here so that I continue to receive onStatus event notifications?

Thanks In Advance...

Not Receiving OnStatus Event After "NetStream.Play.Stop" Event Is Received
Hi,

I am trying to play flv file in swf, using NetStream. I have registered for onStatus event. I receive all the events till I receive "NetStream.Buffer.Flush" & "NetStream.Play.Stop" in same order at the end of the video... After that when I drag the video using seek and play the video again, I don't receive any events in registered call back onStatus function...

I need to make status text updates on video, even after video has fully downloaded and stopped & if replayed... Any idea what is going on and what I need to do different here so that I continue to receive onStatus event notifications?

Thanks In Advance...

Resume Play Than Restart Play On The Play Button.
I have this script that works but it keeps on starting from the start of the song, than resume from where I stopped it.

myMusic = new Sound();
myMusic.loadSound("audio/track.mp3", true)
stopbtn.onRelease = function()
{
trace("sound stopped");
myMusic.stop();
};

playbtn.onRelease = function()
{
trace("sound played");
myMusic.start();
};

How do I change this code to resume when pressing the play button than starting from the start of the song. I guess it be more like a pause button than a play button.

Loading Movie IsSues And Other Issues
i have a main movie and i when an name is cliked on the navigation bar i would like the new movie to load. so there are seeral issues i am having..

1. i am not sure if i am doing this correctly - i am trying to use tutorials.
2. when i load the "services" movie my text will not show up either.
3. i need help by some one that has a lot will be nice i am in a learning phase

CAN SOME ONE PLEAE HELP

THIS IS THE LINK - GIV EIT AINUTE I HAVE NOT PUT ANY PRELOADERS UP YES. I CAN SEND THE FLA FILES FOR MORE HELP

Browswer Size Issues + New "FlashObject" Detection Kit Sizing Issues
Hi,

After a few years of trying to learn Flash there is one aspect that really still remains a grey area to. What size to publish a movie.

Do I look to make my movies a set size on publishing – by using “Match Movie” & if so what should that set size be – 800 x 600?

I know of 3 other ways to get round the browser size issue

1.) Use the “Stage Object” in conjunction with onResize to allow some clips to fill a screen while keeping others to a set size.
2.) Ascertain a users browsers size & direct them to an appropriate version of your site.
3.) Scale your movie according to an ascertained browser size so if the movie was designed @ 1020 x 760 & the user has an 800 x 600 you scale the main movie accordingly using x & y scale.

The problem has been somewhat complicated for me by the introduction of Geoff Stearns brilliant “FlashObject” detection kit. With that you have to specify the size of the element that the Flash movie will load into & also set a fixed size for the Flash movie. From what I can see this will cut out the option of publishing a movie @ 100% & resizing or not resizing using the stage object.

Could someone please advise me of what is best practice as far as sizing is concerned.

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