|
-
[RESOLVED] AS2: Netstream Problem...
I'm currently building a custom flv player and need some help. I've followed the vid tutorial on this site which helped out a lot, but now I'm stuck on a few things. Maybe I'm missing something, I'm not sure. The main problem is that the FLV doesn't load/play, which most likely causes the secondary problems, such as the bufferClip always visible and no way to test the video and audio scrubbers.
Code:
var nc: NetConnection = new NetConnection();
nc.connect(null);
var ns: NetStream = new NetStream(nc);
ns.setBufferTime(5);
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"){
gotoAndStop("end");
}
}
//video location
videoPlace.attachVideo(ns);
ns.play("URL of FLV");
//audio control
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth())
vSound.attachAudio(ns);
var so:Sound = new Sound(vSound);
audioControl.audioScrub.onEnterFrame=function(){
so.setVolume(100-this._y);
}
audioControl.audioScrub.onPress=function(){
this.startDrag(false,this._x,0,this._y,100);
}
audioControl.audioScrub.onRelease = audioControl.audioScrub.onReleaseOutside = function(){
this.stopDrag();
}
//restart button
controlBar.restartBtn.onRelease = function(){
ns.seek(0);
}
//Play and Pause button
controlBar.playpause.onRelease = function(){
ns.pause();
}
//setup the video interval
var vidInt = setInterval(videoStatus, 100);
var amtLoad:Number;
var duration:Number;
ns["onMetaData"] = function(obj){
duration = obj.duration;
}
function videoStatus(){
amtLoad = ns.bytesLoaded/ns.bytesTotal;
loader_mc.loadBar._width = amtLoad * 560;
loader_mc.scrubber._x = ns.time/duration * 560;
}
//scrubber code
var scrubInt;
loader_mc.scrubber.onPress = function(){
clearInterval(vidInt);
scrubInt = setInterval(scrubIt,10);
this.startDrag(false,0,this._y,560,this._y);
}
loader_mc.scrubber.onRelease = loader_mc.scrubber.onReleaseOutside = function(){
clearInterval(vidInt);
vidInt = setInterval(videoStatus,100);
this.stopDrag();
}
function scrubIt(){
ns.seek(Math.floor((controlBar.loader_mc.scrubber._x/560) * duration));
}
Thank you for your help in advance. If you need anymore info, just let me know.
~sg123
-
UPDATE:
Problem solved elsewhere.
-
Which is nice. Nicer would be to share the solution and mark that thread resolved, for the search results.
Thanks in advance.
gparis
-
Okay, fair enough. I'll go through the problems and how they were solved one by one. I should mention where I got the help: on the Adobe Forums.
Problem 1 :: Video won't play
Solution :: Easy. Place the player in the same folder as the FLV and only use the filename for the video instead of the full URL
Code:
ns.play("filename.flv")
instead of
Code:
ns.play("http://www.thissite.com/filename.flv")
*The video mc must have the instance name of videoPlace in order for this to work.
This will give the loader_mc, scrubber, controlBar.playpause, controlBar.replayBtn & audioControl.audioScrub something to react to. The audioControl.audioScrub code works as I had originally written it.
Problem 2:: the video doesn't react to the dragging of the loader_mc.scrubber
Solution:: Simple mixup. In some places, I wrote controlBar.loader_mc.scrubber and in others I wrote loader_mc.scrubber. It should've been the second instance name in all needed places.
Problem 3:: Make the playpause mc react to whether the video is paused.
Solution:
I have it set up as an MC with 4 frames: playon, playoff, pauseon, pauseoff. The "on" frames are for the .onPress function and the "off" frames are for the .onRelease, .onReleaseOutside, .onRollOver and .onRollOut functions. I'm guessing in order for the right state to show ("playoff" when video is playing, "pauseoff" when video is paused).
Then I use toggle-logic:
Code:
controlBar.playpause.onPress=function(){
if(this.toggle){ // or !this.toggle if this starts paused
controlBar.playpause.gotoAndStop("playon");
ns.play();
}
else{
controlBar.playpause.gotoAndStop("pauseon");
ns.pause();
}
this.toggle=!this.toggle
}
There you have it! All the problems answered.
-
Now that is very nice, thank you 
gparis
-
Yeah, sorry about being so blunt earlier.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|