I have a video streaming application that uses a Red5 server. The stream from Red5 is represented through an embedded video object on stage. I need to be able to control the volume of this video object, but so far I’ve been unsuccessful despite following tutorials like this one: http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001486.html.
Here’s the relevant code:
function connect():Boolean {
this.nc = new NetConnection();
this.nc.onStatus = Delegate.create(this, this.ncOnStatus);
var connected:Boolean = this.nc.connect(streamAddress);
tt("connected?",connected);
return connected;
}
function initNetStream() {
this.ns = new NetStream(this.nc);
}
function playMovie(what) {
stopVideo();
initNetStream();
ns.setBufferTime(5);
this.videoContainer.attachVideo(this.ns);
ns.play(what);
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(this.ns);
var videoSound:Sound = new Sound(vSound);
trace(videoSound.getVolume());
}
function volumeChange() {
volumeFactor++;
if(volumeFactor >= 4) {
volumeFactor = 0;
}
videoSound.setVolume(33.3 * volumeFactor);
}
I have a button calling volumeChange onRelease, but when I trace videoSound.getVolume() in volumeChange, it comes up as undefined. However, if I trace videoSound.getVolume() after I define videoSound, it comes up as 100, but any attempt to use videoSound.setVolume in initNetStream is futile.
Thank you for reading this. I look forward to your suggestions.