Skip to main content
May 3, 2009
Answered

getting a flv file to start playing with no sound

  • May 3, 2009
  • 1 reply
  • 677 views

Hello,

I am trying to get my flv file to start playing when the page is loaded with no sound, but I am have no luck. The flv file starts playing fine with the sound on, and I can turn the sound off with my volume controller, but I need it to start playing with no sound. Please help.

var restartTimer:Timer = new Timer(19000,1);

restartTimer.addEventListener(TimerEvent.TIMER, startTimer)

var myImage:mcImage = new mcImage;

var myReplayBtn:mcReplayBtn = new mcReplayBtn;

//--------------------Video Controls---------------------

var videoConnection:NetConnection = new NetConnection();

videoConnection.connect(null);

var videoStream:NetStream = new NetStream(videoConnection);

videoStream.play("sebring09.flv")

var metaListener:Object = new Object();

metaListener.onMetaData = onMetaData;

videoStream.client = metaListener;

var video:Video = new Video(195,132);

video.attachNetStream(videoStream);

addChild(video)

swapChildren(whiteOutline, video)

video.mask = myMask

video.x = 7.5;

video.y = 3;

function onMetaData(data:Object):void

{

}

//------------------------Timer---------------------

function startTimer(event:TimerEvent):void

{

addChild(myImage)

myImage.x = 9;

myImage.y = 20;

addChild(myReplayBtn)

myReplayBtn.x = stage.stageWidth/2;

myReplayBtn.y = stage.stageHeight/2 - 12;

myReplayBtn.addEventListener(MouseEvent.CLICK, replayMovie)

myReplayBtn.buttonMode = true;

}

function replayMovie(event:MouseEvent):void

{

videoStream.play("09_Sebring_incar_Cut.flv");

removeChild(myImage)

removeChild(myReplayBtn)

restartTimer.start();

}

restartTimer.start();

//-------------------------Audio Controls---------------------------------

var soundVol:SoundTransform = new SoundTransform();

var soundVolume:Number = 1;

// Code that handles the volume slider

var trackBounds:Rectangle = track_mc.getBounds(track_mc);

var xPos:Number = trackBounds.x;

var yPos:Number = trackBounds.y;

var widthPos:Number = trackBounds.width-track_mc.slider_mc.width;

var heightPos:Number = 0;

var bounds:Rectangle = new Rectangle(xPos,yPos,widthPos,heightPos);

track_mc.slider_mc.x = widthPos;

track_mc.mouseEnabled = false;

track_mc.slider_mc.buttonMode = true;

track_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragSlider);

stage.addEventListener(MouseEvent.MOUSE_UP,stopSlider);

function dragSlider(event:MouseEvent):void {

event.target.startDrag(false,bounds);

addEventListener(Event.ENTER_FRAME,setVolume);

}

function stopSlider(event:MouseEvent):void {

track_mc.slider_mc.stopDrag();

removeEventListener(Event.ENTER_FRAME, setVolume);

}

function setVolume(event:Event):void {

soundVolume = track_mc.slider_mc.x/widthPos;

soundVol.volume = soundVolume;

SoundMixer.soundTransform = soundVol;

}

This topic has been closed for replies.
Correct answer kglad

you can use the soundmixer's soundtransform to control all volume but, unless you have multiple sounds, you should probably use the netstream's soundtransform.

in either case, to start your video with no sound, assign the volume property in you onMetaData function:

function onMetaData(data:Object):void {
var st:SoundTransform = videoStream.soundTransform;
st.volume = 0;
videoStream.soundTransform = st;
}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 3, 2009

you can use the soundmixer's soundtransform to control all volume but, unless you have multiple sounds, you should probably use the netstream's soundtransform.

in either case, to start your video with no sound, assign the volume property in you onMetaData function:

function onMetaData(data:Object):void {
var st:SoundTransform = videoStream.soundTransform;
st.volume = 0;
videoStream.soundTransform = st;
}
May 3, 2009

Thank you kglad, you rock!!!!!

kglad
Community Expert
Community Expert
May 3, 2009

you're welcome.