Retrieve The Audio LeftPeak From A Video Netstream?
Does anyone out there know to retrieve the audio leftPeak & rightPeak from a video netstream?
(I know SoundChannel has that property but NetStream does not seem to allow itself to be associated with a soundchannel object)
//assuming that stream is a properly initialized NetStream
//the following does not work....
var music_son_sc:SoundChannel;
stream.SoundChannel = music_son_sc
thanks in advance,
jhave
KirupaForum > Flash > ActionScript 3.0
Posted on: 11-12-2008, 12:34 AM
View Complete Forum Thread with Replies
Sponsored Links:
Netstream Audio Plays While Video Loading
hi all,
just managed to work out how to get flv's to load up dynamically using xml - it all works well apart from this one problem that i have.
when the thumbnail for the flv is clicked the preloader appears and the flv starts to load - but for some reason the audio begins to play almost immediately - then when the flv actually loads then the audio plays again whilst the initial (unwanted) audio carries on playing!
this is the script for the netstream:
PHP Code:
private function onInitialize():void
{
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus, false, 0, true);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onConnectionError, false, 0, true);
_connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onConnectionError, false, 0, true);
_connection.addEventListener(IOErrorEvent.IO_ERROR, onConnectionError, false, 0, true);
_connection.objectEncoding = ObjectEncoding.DEFAULT;
_connection.client = {
onBWDone: onBWDone
};
//_connection.connect("rtmp://yourfmshere/");
_connection.connect(null);
}
private function onConnectionError(...args):void
{
trace("Test.onConnectionError()");
}
private function onConnectionNetStatus(event:NetStatusEvent):void
{
trace("**** code **** " + event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success":
_stream = new NetStream(_connection);
_stream.client = {
onMetaData: onMetaData,
onCuePoint: onCuePoint
};
_video = new Video();
_video.smoothing = true;
addChild(_video);
_video.attachNetStream(_stream);
var xscaler:Number = (1 / _video.width) * stage.stageWidth;
var yscaler:Number = (1 / _video.height) * stage.stageHeight;
_video.scaleX = xscaler;
_video.scaleY = yscaler;
_stream.play(videoPath + imageArray[largeImageItem].largeImage, 0);
i really don't understand why it plays double???
Anyone had this problem before?
View Replies !
View Related
NetStream Audio Only...
I have the code working for the net streaming of video. I'm trying to use the same technique for an audio only player. It doesn't work. Here is what I have: What am I missing?
Attach Code
var nc:NetConnection = new NetConnection();
nc.connect(null);
//
//-------------- Create Netstream ----------------
//
var ns:NetStream = new NetStream(nc);
_root.createEmptyMovieClip("vidSound", 99);
vidSound.attachAudio(ns);
var vSound:Sound = new Sound(vidSound);
vSound.setVolume(75);
ns.play("Media/Acts/Audio/test.mp3");
View Replies !
View Related
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?
View Replies !
View Related
Retrieve A Video From Ifilm To Edit On My Pc
Is it possible to somehow strip the raw clip from ifilm or youtube so I can save it on my hard drive then open it up in a movie editor?
I stripped the address out of the embed code they provide you and entered it into the address bar directly so it would open up in my default video player but it doesn't work.
Thanks
View Replies !
View Related
Netstream Plays Audio Twice
hi all,
just managed to work out how to get flv's to load up dynamically using xml - it all works well apart from this one problem that i have.
when the thumbnail for the flv is clicked the preloader appears and the flv starts to load - but for some reason the audio begins to play almost immediately - then when the flv actually loads then the audio plays again whilst the initial (unwanted) audio carries on playing!
this is the script for the netstream:
PHP Code:
private function onInitialize():void
{
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus, false, 0, true);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onConnectionError, false, 0, true);
_connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onConnectionError, false, 0, true);
_connection.addEventListener(IOErrorEvent.IO_ERROR, onConnectionError, false, 0, true);
_connection.objectEncoding = ObjectEncoding.DEFAULT;
_connection.client = {
onBWDone: onBWDone
};
//_connection.connect("rtmp://yourfmshere/");
_connection.connect(null);
}
private function onConnectionError(...args):void
{
trace("Test.onConnectionError()");
}
private function onConnectionNetStatus(event:NetStatusEvent):void
{
trace("**** code **** " + event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success":
_stream = new NetStream(_connection);
_stream.client = {
onMetaData: onMetaData,
onCuePoint: onCuePoint
};
_video = new Video();
_video.smoothing = true;
addChild(_video);
_video.attachNetStream(_stream);
var xscaler:Number = (1 / _video.width) * stage.stageWidth;
var yscaler:Number = (1 / _video.height) * stage.stageHeight;
_video.scaleX = xscaler;
_video.scaleY = yscaler;
_stream.play(videoPath + imageArray[largeImageItem].largeImage, 0);
i really don't understand why it plays double???
Anyone had this problem before?
View Replies !
View Related
NetStream (Audio) (MX 2004)
Hi there.
Can someone please shed some light on the NetStream function?
1. Does this allow me to stream an audio file from an alternative source rather than compiling it into my flash file?
2. What audio formats support it?
3. I am trying to develop background music for my flash document that auto-starts, with music on/off buttons and I do not want it to slow down the pre-loader. Any other suggestions would be greatly appreciated. Thanks.
View Replies !
View Related
Problem With Streaming Audio From A NetStream
Hi
I have a problem with streaming audio from a netStream and I haven't found any reference that someone else might be having a problem like this. I have one client capturing video and audio from a webcam, publishing it to the flash media server (running on the same machine), and then another client (on another machine), playing that audio/video netStream.
I have Flash Media Server 2, developers edition.
Now, if I publish only video, there is no problem, I get a fairly good fps of almost 15 over a local network, the video plays fine with almost no lag.
But if I add audio to it, or publish only audio, the video plays fine while there is not enough sound to start streaming sound, but when audio starts streaming, video slows down and so does audio, literally (!). It sounds like slow motion, not just slow but also pitch shifted.. And lags considerately, the longer it continuosly sends audio the longer it lags.
I have tried seprating into two streams, for video and audio and I have tried sending only audio, and I get the same result.
I have tried capturing sound with 5kHz instead of 8, and the sound shifts up! Not as much as when it slows down, but you can notice that it is higher pitched, and has short gaps (I guess it runs out of data in between)
Now I am completely bewildered, I thought this was supposed to work pretty much "out of the box", I don't know what else to try. I could understand sound cutting off and then continue after a short break if it can't get through the bandwidth, but I can't believe that actually slowing down is how this is supposed to work.
And I can't believe there isn't enough bandwidth, because this is over a local network and it's only 8kHz and only one sending and one recieving client. (besides, the video alone , which I imagine should have more data than audio, streams fine).
But on the other hand, if i try running both clients on the same machine that the flash media server is running on, I don't get this problem. (Othervise, only the sending client runs on the serving machine)
I hope someone can help out with this, I'm out of ideas.
Thanks
Edited: 01/18/2007 at 05:42:47 AM by cicnats
View Replies !
View Related
Displaying Audio Amplitude For A NetStream
I want to have a similar output to the example here: http://www.marcofolio.net/actionscript/visualize_audio_bars_by_using_amplitude_in_flash.html
but instead of the audio coming from an mp3 file via a URLRequest, I want the audio to come from a NetStream originating from a Flash Media Server.
The ultimate goal is to have multiple netstreams coming in each with their own audio amplitude bar being displayed.
This is being written in Flex 3 using Actionscript 3.
The API docs for NetStream.play() (@ http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html#play() ) says the following:
"To control the audio associated with a video file, you can use the DisplayObjectContainer.addChild() method to route the audio to an object on the display list; you can then create a Sound object to control some aspects of the audio. For more information, see the DisplayObjectContainer.addChild() method."
but the DisplayObjectContainer.addChild() method doesn't provide any further information and I cannot figure out how to use an AS3 Sound or SoundChannel object with a DisplayObjectContainer or a NetStream.
View Replies !
View Related
Displaying Audio Amplitude For A NetStream
I want to have a similar output to the example here: http://www.marcofolio.net/actionscript/visualize_audio_bars_by_using_amplitude_in_flash.html
but instead of the audio coming from an mp3 file via a URLRequest, I want the audio to come from a NetStream originating from a Flash Media Server.
The ultimate goal is to have multiple netstreams coming in each with their own audio amplitude bar being displayed.
This is being written in Flex 3 using Actionscript 3.
The API docs for NetStream.play() (@ http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html#play() ) says the following:
"To control the audio associated with a video file, you can use the DisplayObjectContainer.addChild() method to route the audio to an object on the display list; you can then create a Sound object to control some aspects of the audio. For more information, see the DisplayObjectContainer.addChild() method."
but the DisplayObjectContainer.addChild() method doesn't provide any further information and I cannot figure out how to use an AS3 Sound or SoundChannel object with a DisplayObjectContainer or a NetStream.
View Replies !
View Related
LeftPeak Action
Hi! I'm new to flash, but wanna make a background flash to the music I'm playing...
So how can I go to a keyframe in a movieclip if the value of the leftpeak in the soundchannel is above say 0.5?
hope someone can help!
cheers..
View Replies !
View Related
SoundChannel.leftPeak
Has anyone used this yet. I'm having trouble getting it to work.
I basically created a new Sound, which works fine. I can get the sound to play too.
I just cant get the leftPeak or rightPeak to return a value.
Its telling me it doesn't recognize leftPeak or rightPeak as methods?
>???
View Replies !
View Related
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
View Replies !
View Related
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?
View Replies !
View Related
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
View Replies !
View Related
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");
View Replies !
View Related
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
View Replies !
View Related
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?
View Replies !
View Related
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.
View Replies !
View Related
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!
View Replies !
View Related
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.
View Replies !
View Related
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");
View Replies !
View Related
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.
View Replies !
View Related
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
View Replies !
View Related
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.
View Replies !
View Related
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?
View Replies !
View Related
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?
View Replies !
View Related
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
View Replies !
View Related
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!
View Replies !
View Related
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 = "";
}
}
View Replies !
View Related
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");
}
View Replies !
View Related
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
View Replies !
View Related
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
View Replies !
View Related
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?
View Replies !
View Related
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! :(
View Replies !
View Related
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!
View Replies !
View Related
[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
View Replies !
View Related
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
View Replies !
View Related
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
}
View Replies !
View Related
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
View Replies !
View Related
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");
View Replies !
View Related
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
View Replies !
View Related
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();
View Replies !
View Related
OnClick Start A Netstream Video .flv
Hi everybody, I'm looking for some help here. I'm using the Scroling thumbnail tutorial to make a video gallery of my project. Since I'm a editor and not a flash web programmer, I have some difficulty with the code when become time to link the buttons to the netstream windows.
Other thing. When I was finaly able to link button to the video, the video doesn't play the full lenght. It stop in the middle. Well It never stop at the same place.
Here are the code so far:
panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);
function panelOver(event:MouseEvent):void {
panel.removeEventListener(MouseEvent.MOUSE_OVER, panelOver);
panel.addEventListener(Event.ENTER_FRAME, scrollPanel);
}
var b:Rectangle = stroke.getBounds(this);
function scrollPanel(event:Event):void {
if(mouseX < b.left || mouseX > b.right || mouseY < b.top || mouseY > b.bottom) {
panel.removeEventListener(Event.ENTER_FRAME, scrollPanel);
panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);
}
if(panel.x > 50) {
panel.x = 50;
}
if(panel.x < -689) {
panel.x = -689;
}
var xdist = mouseX - stage.stageWidth / 2;
panel.x += -(xdist / 7);
}
var video:Video = new Video(428, 240);
addChild(video);
video.x=240;
video.y=211;
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
{
trace(stat.info.code);
}
var meta:Object = new Object();
meta.onMetaData = function(meta:Object)
{
trace(meta.duration);
}
ns.client = meta;
video.attachNetStream(ns);
panel.smpq.addEventListener(MouseEvent.CLICK,Navigation)
function Navigation(event:MouseEvent):void{
ns.play("video/SMPQ.flv");
}
panel.ak.addEventListener(MouseEvent.CLICK,Navigation2)
function Navigation2(event:MouseEvent):void{
ns.play("video/AK27_trailler.flv");
}
Thank you for your help... I'll add my play, stop and seek button later on... For now, I want to be able to switch the video with the button.
Nicolas
View Replies !
View Related
Video Stops And Audio Continues - Individual Scenes Work, Together Video Freezes
This is my first flash project ever, but I think I got a handle on layers, scenes, using streamed audio, etc. The sync works for every scene when tested independently. Those exported .swf run fine. But when I try to publish the entire movie as a .swf or .exe or any other format, it always freezes at a certain point. The video stops but the audio continues.
Can anyone help me or give me an idea of where to start diagnosing the issue?
I've resorted to converting each individual .swf into .avis then combining the segments into the video that I want, but, of course, this doesn't retain the size, scalability, and quality benefits of a .swf file. Please help!
View Replies !
View Related
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?
View Replies !
View Related
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.
View Replies !
View Related
Netstream Video - Back Button Chaos
Hi everyone,
I am having a problem regarding a NetStream-based FLV player in AS3. This problem occurs using the simplest player, with no controls, streaming a local-stored FLV.
I just need to add a "Back" button in the layout that sends back to frame 1. When the frame 4 was without the video, the back button worked fine, but when I add the video player code - wich plays the video with no problems - pressing the back button returns to frame 1, but messing all up:
- all the animations loop, no buttons are working anymore;
- TypeError: Error #1009: Cannot access a property or method of a null object reference. at TSLDemosv0_fla::MainTimeline/TSLDemosv0_fla::frame1()
The question is: how to get the Back button work properly?
Adding ns.close(); at the Back button function didnt't help.
ActionScript Code:
stop();
//== Video Player ======================================
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var FLV1:Video = new Video(450, 360);
this.addChild(FLV1);
FLV1_1.attachNetStream(ns);
ns.play("Movies/demo-movie.flv");
ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent) {
trace(stats.info.code);
}
var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object) {
trace(meta.duration);
};
ns.client = netClient;
//== Additional Controls ==================================
function clickMovie1_1b( pEvent:MouseEvent) {
ns.close();
gotoAndPlay(1);
trace("Frame4: Detected click on back button, going back");
}
Movie1_1b.addEventListener(MouseEvent.CLICK, clickMovie1_1b);
The resulted output is:
Code:
Frame1: Detected click on Movie 1, Loading movie (Going to Frame 4)
NetStream.Play.Start
106.4
NetStream.Buffer.Full
Frame4: Detected click on back button, going back
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TSLDemosv0_fla::MainTimeline/TSLDemosv0_fla::frame1()
I googeled and searched lots of forums but the results were minimal.
I appreciate any help on this. Thanks in advance.
M0rph.
View Replies !
View Related
|