dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: Playing multiple flvs from buttons. Help!

  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    51

    Playing multiple flvs from buttons. Help!

    I'm trying to fire off different flvs into a player i've created using a separate button thumbnail for each flv but I can't seem to figure out the code. Can anyone help?

    Thanks, in anticipation... P

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    What version of flash?

  3. #3
    Member
    Join Date
    Nov 2005
    Posts
    51
    I'm using version 8 but I want to create a website that can be viewed without having to update their player so my publish settings will be 7.


    Thanks

  4. #4
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Here's an example. this will cycle through them automatically on complete, or from a button.
    Attached Files Attached Files

  5. #5
    Member
    Join Date
    Nov 2005
    Posts
    51
    Hey, man - thanks so much. I'll give it a try right now. Best Peter

  6. #6
    Member
    Join Date
    Nov 2005
    Posts
    51
    Hey again -

    thanks for the example. If I understand this correctly, I put the netstream block of code on each button with a different flv in each.

    Do I need to close the netstream when each movie is finished or does that happen automatically when the buttons switch?

    Thanks again. P

  7. #7
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    No, put the code to play the movie on a frame, and only tell the buttons to go to the right frame. The video object stays the same.

    Just loading a new flv from the frame bumps out the one playing and loads the new one. It's like loading anything else, an object or level can only hold one at a time.

  8. #8
    Member
    Join Date
    Nov 2005
    Posts
    51
    Right. So I need a separate frame for each video and then I tell each thumnbnail to go to a different frame label or number. I'll give that a go. Thanks again. P

  9. #9
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    You can also make a controller movie clip. Put the code in frames inside that, then have the buttons tell it to go to the proper frame. That way you don't have to make frames on the main timeline, if that's important.

  10. #10
    Member
    Join Date
    Nov 2005
    Posts
    51
    I've already made a controller and I was trying to figure out how that fitted in. As I've built the rest of the site it would be easier if I didn't have to add extra frames into the main timeline. I'll try your suggestion.

    Thanx again. P

  11. #11
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Like this.
    Attached Files Attached Files

  12. #12
    Member
    Join Date
    Nov 2005
    Posts
    51
    Yes. It works a treat. Thanks for your help.

    If you can spare the time - just a couple of quick things. If I want to put some basic controls, play, stop and go back to the beginning and play, would I do those on the video layer or the controller layer?

    Also, some of my videos are in 16:9 (320 x 180) and some are in 3:4 (240 x 180). How would you approach the changing of aspect ratio for different videos?

    Best, Peter

  13. #13
    Member
    Join Date
    Nov 2005
    Posts
    51
    By dragging out another instance of the Embed video and giving it the instance name of my_Video2 brings it on to the screen at the correct aspect ratio, but then the old 16:9 video is still on the screen behind it - as you'd expect. Sorry, this is just way beyond my knowledge.

    Best,

    Peter

  14. #14
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Attach your fla if you can. My examples used the video object. Not sure what your using with controls.

  15. #15
    Member
    Join Date
    Nov 2005
    Posts
    51
    Hi - I'm using the last flv you attached as the template which works perfectly. I changed the Embedded Video 1 (my_video) to 320 x 180 and my flvs play perfectly until time comes to play a 3:4 video (240 x 180) which then stretches on the horizontal.

    My site has both a still image gallery and a video gallery. In the image gallery page I got around this problem - I use the MovieClipLoader to load Jpegs into a holder_mc - by repositioning the holder_mc using two functions, depending upon whether the jpeg being loaded was in 16:9 or 3:4, similar to this:

    function square () {
    _root.holder_mc._x = 225;
    }
    function wide () {
    _root.holder_mc._x = 165;
    }

    and then calling the relevant function for the code on each button:

    this.panel40.btn_gal_40_01.onRelease = function () {
    _root.wide ();
    var loader:MovieClipLoader = etc etc.

    which works fine for jpegs.

    I currently have my set up for the videos page using the same kind of arrangements using loadMovie and loading the video in as an swf. So I can use the same kind of function to reposition the videoholder_mc.

    But I'd really like to use the right netstream code and load flvs directly. So that's where I'm at with it. The flv you sent me (the second one) works a treat, but I can't figure out how to handle the differing aspect ratios of the two types of videos.

    My site flv is currently weighing in at around 3M so it's a bit too big to post.

    Anyhow, any insight you have would be appreciated.

    Best,


    Peter
    Last edited by psch12; 12-02-2005 at 06:50 PM.

  16. #16
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    If you want a controller, use the media display component. Make it big enough to hold the biggest movie, the others will load in the center.

    http://www.learningflashmx.com/fla/s...ontroller1.zip

  17. #17
    Member
    Join Date
    Nov 2005
    Posts
    51
    Hi again -

    thanks for your flv. The media display works really well. It handles the different aspect ratios, no problem. But the controller is so totally wrong for the design of my site.

    I really just want a play, stop and rewind button. Small and discreet. Is there a way to use simple buttons with code for play stop and rewind with the Media Display component or does the media display only work with the media controller component?

    Sorry to be such a dummy about this but it's really out of my league. Maybe there's a 101 tutorial on video you know of, or a site that explains how video works. I've done all of the gotoAndLearn sites but perhaps there are others you can direct me to. I don't want to waste any more of your time but I'd really like to crack this...

    Thanks for your patience...

    Cheers Peter

  18. #18
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    As far as I know the media controller doesn't bind to the video object, which in reality is not a component but an object. Not saying there isn't a way, but I don't know it.

    I think there are component parts in the component panel where you can build what you want. Not sure how to use them all or if it's available in 04. F8 has them tho.

    Use the reference file or Live Docs from the Help menu. That's where I've learned all this.

  19. #19
    Member
    Join Date
    Nov 2005
    Posts
    51
    Mate - thanks. I appreciate the trouble you've taken to help me out. Best Wishes, Peter

  20. #20
    SnowKrash
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    32
    Just in case this would help someone else (like it would have helped me) looking at this thread, I'm going to post the code that worked for me that took me forever to figure out.

    I am in Flash 8, so I wouldn't know if this would work in other versions, but if you are in Flash 8, it works like a dream.

    Using the tutorials at http://www.gotoandlearn.com I created my own player with controls, but instead of having a video play automatically on loading, I assigned buttons to the thumbs I wanted to play, and I still kept all the code on one page on the actions layer, as described in the tutorial. (I also happened to add a splash screen to look at before any button was pressed to load a video) This is my fifth week using flash, so it may not be the most elegant way to code this, I don't know, but it works, so here it is (sorry if it's more than you need, I thought it might be helpful to put the entire page of code here in case someone needed it -- it's pretty easy to pick out of this the part that you need):

    Code:
    bufferClip._visible = false;
    splashClip._visible = true;
    
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    	
    theVideo.attachVideo(ns);
    ns.setBufferTime(20);
    	
    ns.onStatus = function(info) {
    	trace(info.code);
    	if(info.code == "NetStream.Buffer.Full") {
    		bufferClip._visible = false;
    	}
    	if(info.code == "NetStream.Buffer.Empty") {
    		bufferClip._visible = true;
    	}
    	if(info.code == "NetStream.Play.Stop") {
    		ns.seek(0);
    		ns.pause();
    	}
    }
    adButton.onRelease = function() {
    	bufferClip._visible = true;
    	splashClip._visible = false;
    	ns.play("http://www.krashonline.com/whatever.flv");
    }
    
    qButton.onRelease = function() {
    	bufferClip._visible = true;
    	splashClip._visible = false;
    	ns.play("http://www.krashonline.com/whatever2.flv");
    }
    
    playButton.onRelease = function() {
    	ns.pause();
    }
    
    stopButton.onRelease = function() {
    	ns.seek(0);
    	ns.pause();
    }
    
    replayButton.onRelease = function() {
    	ns.seek(0);
    }
    
    var videoInterval = setInterval(videoStatus,100);
    var amountLoaded:Number;
    var duration:Number;
    
    ns["onMetaData"] = function(obj) {
    	duration = obj.duration;
    }
    
    function videoStatus() {
    	amountLoaded = ns.bytesLoaded / ns.bytesTotal;
    	vidLoader.vidLoadbar._width = amountLoaded * 196.9;
    	vidLoader.scrub._x = ns.time / duration * 196.9;
    }
    
    var scrubInterval;
    
    vidLoader.scrub.onPress = function() {
    	clearInterval(videoInterval);
    	scrubInterval = setInterval(scrubit,10);
    	this.startDrag(false,0,this._y,190,this._y);
    }
    
    vidLoader.scrub.onRelease = vidLoader.scrub.onReleaseOutside = function() {
    	clearInterval(scrubInterval);
    	videoInterval = setInterval(videoStatus,100);
    	this.stopDrag();
    }
    
    function scrubit() {
    	ns.seek(Math.floor((vidLoader.scrub._x/190)*duration));
    }
    
    _root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
    vSound.attachAudio(ns);
    
    var so:Sound = new Sound(vSound);
    
    so.setVolume(50);
    
    mute.onRollOver = function() {
    	if(so.getVolume()> 0) {
    		this.gotoAndStop("onOver");
    	}
    	else {
    		this.gotoAndStop("muteOver");
    	}
    }
    
    mute.onRollOut = function() {
    	if(so.getVolume()> 0) {
    		this.gotoAndStop("on");
    	}
    	else {
    		this.gotoAndStop("mute");
    	}
    }
    
    mute.onRelease = function() {
    	if(so.getVolume()> 0) {
    		so.setVolume(0);
    		this.gotoAndStop("muteOver");
    	}
    	else {
    		so.setVolume(50);
    		this.gotoAndStop("onOver");
    	}
    }
    So, you can see, if you look at this part:

    Code:
    adButton.onRelease = function() {
    	bufferClip._visible = true;
    	splashClip._visible = false;
    	ns.play("http://www.krashonline.com/whatever.flv");
    }
    
    qButton.onRelease = function() {
    	bufferClip._visible = true;
    	splashClip._visible = false;
    	ns.play("http://www.krashonline.com/whatever2.flv");
    }
    You can just keep making new thumbnails, turn them into buttons, and add as many as you want. The only thing I didn't address here is if your clips are not the same height and width, but that seemed to be worked out above in the thread. I hope this helps someone.
    Last edited by SnowKrash; 12-23-2005 at 01:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center