Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-06-2012, 08:32 PM   #1
vdubplate
Senior Member
 
Join Date: Oct 2007
Location: Denver
Posts: 138
Default Can you pause audio of a netstream video

Ive been googling for the last hour how to do this. So frustrating! I have a video player I'm making in flash. I need a mute button for the audio of a net streaming video. Can someone point me In the right direction?

Thanks in advance
vdubplate is offline   Reply With Quote
Old 08-06-2012, 09:26 PM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,331
Default

I have an example of a video player with mute button.
The example uses Greensock LoaderMax instead of the Adobe classes.
The LoaderMax reduces the code for adjusting the volume to a single property of the VideoLoader.
ie: myVid.volume = 0;

I'll post the code if you're interested in this approach.
[afz]snickelfitz is offline   Reply With Quote
Old 08-06-2012, 11:37 PM   #3
vdubplate
Senior Member
 
Join Date: Oct 2007
Location: Denver
Posts: 138
Default

Yea that would be great. I use greensock's tweening engine for everything. Would be cool to see a good working example of LoaderMax. Any way I can shorten up my code would be great. Ihave to do a lot more video stuff at work now so would be good to use something where I could hit the forums for some best practices. Not that easy now that people are not using Flash as much anymore
vdubplate is offline   Reply With Quote
Old 08-07-2012, 01:18 AM   #4
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,331
Default

Not sure how good this code is (in absolute terms), but it seems to work pretty well as is.
I wrote this in May as an experiment and never completely finished it.
Requires a MovieClip in the Library exported to Btn.
Inside Btn, there is a textfield named "buttonLabel".
ActionScript Code:
import flash.display.*; import flash.events.*; import com.greensock.*; import com.greensock.easing.*; import com.greensock.events.*; import com.greensock.loading.*; import com.greensock.loading.display.*; import com.greensock.loading.data.*; LoaderMax.activate([VideoLoader]); // liquid GUI stage.addEventListener(Event.RESIZE, onResize); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; var sw:Number; var sh:Number; var swCenter:Number; var shCenter:Number; // app data var links:Array = [ "video1.flv", "video2.flv", "video3.flv", "video4.flv", "video5.flv", ]; var videos:Array = new Array(); var buttons:Sprite = new Sprite(); // the video object var currVid:VideoLoader; var prevVid:VideoLoader; // track the current and previous video Sprite container var currDisplay:ContentDisplay; var prevDisplay:ContentDisplay; var mute:Btn; var muted:Boolean; var buttonX:Number = 0; var index:int = 0; var pad:Number = 5; // load each video in the links array, one at a time var loaders:LoaderMax = LoaderMax.parse(links,                                         new LoaderMaxVars()                                         .maxConnections(1)                                         .onComplete(parentComplete)                                         .onChildComplete(childComplete),                                         new VideoLoaderVars()                                         .autoPlay(false)                                         .x(stage.stageWidth/2)                                         .y(stage.stageHeight/2)                                         .width(400)                                         .height(300)                                         .centerRegistration(true)                                         .scaleMode("proportionalOutside")                                         .smoothing(true)); // append the server directory to the links loaders.prependURLs("videos/"); loaders.load(); function childComplete(e:LoaderEvent):void {     videos.push(e.target);         // Btn is a MovieClip in the Library     // Btn contains a dynamic textfield "buttonlabel"     var b:Btn = new Btn();     b.id = index;     b.buttonMode = true;     b.mouseChildren = false;     b.addEventListener(MouseEvent.CLICK, onClick);     b.buttonLabel.text = "video" + index.toString();     b.buttonLabel.autoSize = TextFieldAutoSize.LEFT;     b.x = buttonX;     buttons.addChild(b);         buttonX = buttons.width + pad;     index++; } function parentComplete(e:LoaderEvent):void {     // load first video     prevVid = videos[0] as VideoLoader;     prevVid.playVideo();     prevDisplay = prevVid.content;         // build mute button     mute = new Btn();     mute.buttonLabel.autoSize = TextFieldAutoSize.LEFT;     mute.buttonMode = true;     mute.mouseChildren = false;     mute.addEventListener(MouseEvent.CLICK, toggleSound);     mute.x = mute.y = 0;     resetMute();         addChild(prevDisplay);     addChild(buttons);     addChild(mute);         // tween the alpha for the first video and the buttons     TweenMax.allFrom([prevDisplay, buttons], 1, {onStart:onResize, alpha:0}, .1); } // toggle muted/unmuted function toggleSound(e:MouseEvent):void {     var vol:Number;     var t:String;         if(!muted)     {         t = "unMute";         vol = 0;     }     else     {         t = "Mute";         vol = 1;     }         mute.buttonLabel.text = t;     TweenMax.to(prevVid, 1, {volume:vol});     muted = !muted; } // utility function that resets the mute button to initial state function resetMute():void {     muted = false;     mute.buttonLabel.text = "Mute"; } function onClick(e:MouseEvent):void {     resetMute();         prevVid.pauseVideo();     removeChild(prevDisplay);         prevVid = videos[e.target.id] as VideoLoader;     prevVid.gotoVideoTime(0, true);         currDisplay = prevVid.content;     currDisplay.alpha = 1;     addChild(currDisplay);         TweenMax.from(currDisplay, .5, {width:prevDisplay.width, ease:Linear.easeInOut});     TweenMax.from(currDisplay, .5, {delay:.5, height:prevDisplay.height, ease:Linear.easeInOut});         prevDisplay = currDisplay;     onResize(); } // reposition elements when the browser window is resized function onResize(e:Event=null):void {     sw = stage.stageWidth;     sh = stage.stageHeight;     swCenter = sw / 2;     shCenter = sh / 2;         buttons.x = swCenter - buttons.width/2;     prevDisplay.x = swCenter;     prevDisplay.y = shCenter;     mute.x = prevDisplay.x - prevDisplay.width/2;     mute.y = prevDisplay.y + prevDisplay.height/2; }

Last edited by [afz]snickelfitz; 08-07-2012 at 01:37 AM.
[afz]snickelfitz is offline   Reply With Quote
Old 08-07-2012, 01:34 AM   #5
vdubplate
Senior Member
 
Join Date: Oct 2007
Location: Denver
Posts: 138
Default

Cool, Thanks, I'll give this a whirl tomorrow morning. Thanks for sharing.
vdubplate is offline   Reply With Quote
Old 08-24-2012, 05:07 PM   #6
vdubplate
Senior Member
 
Join Date: Oct 2007
Location: Denver
Posts: 138
Default

Would you be able to post a file for this.
The script doesn't format when I copy paste.
vdubplate is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:22 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.