A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: play video -> stop music. Video end -> start music

  1. #1
    Member
    Join Date
    Nov 2003
    Location
    sweden
    Posts
    38

    play video -> stop music. Video end -> start music

    Hi!

    I didn't know whether to post this here or in the videos section.

    I'm making a site with some background music (a loop ~ 1 minute), added through a simple swf which is also a sound on / off button.

    On this site I want visitors to be able to watch a short (self-hosted) video (I'm thinking, maybe jwplayer).

    But instead of forcing the user to first stop the music and then play the video (risking that they might miss to do, thus ruining the movie) I want the music to stop when the video is playing and then to start again when the video has ended.

    I really haven't the faintest how to accomplish this.
    I don't have to have the music in a separate swf, I don't have to have an on / off switch for the music, I don't have to use jwplayer (any simple video playback will suffice).

    Thanks in advance

    Jess

  2. #2
    Senior Member
    Join Date
    Sep 2010
    Posts
    324
    You might be able to do this with JW Player, but I think you would have better luck building your own player and using NetStream to play the video. Using NetStream will allow you to interact with other elments of the .fla, for example, control when a .swf starts to play.
    Here's some info to get you started using NetStream:
    http://www.gotoandlearn.com/index.php?currentpage=13
    Here is code that detects end of flv video file and then jump the main timeline to a frame labeled "play_mp3". There you could have a mp3 player, auto start. When it finishes/or video starts, turn control back to whatever frame your video player is in:
    Code:
    ns.onStatus = function(info) {
    		if(info.code == "NetStream.Play.Stop") {
    		trace("Video complete")
      		gotoAndStop("play_mp3");
    		}
    	}
    A second option would be to encode the mp3 in the container format of .flv and play the mp3 in the video player, after all, .flv is NOT a video format but rather just a container format that may contain, video, video and audio, or just audio.
    Having your mp3 in a flv container would mean you could use just the one media player, no need to switch control back and forth. Just create a playlist which happens to have a video and a separate audio file in the playlist.
    Either way, using NetStream has a lot more possiblilities than either the FLVPlayback component or the JW Player.
    Best wishes,
    Video Man

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