Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

Author Topic: Music Plays Too Long  (Read 8501 times)

0 Members and 1 Guest are viewing this topic.

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Music Plays Too Long
« on: March 11, 2009, 10:37:25 PM »

I have one music file for a few scenes but when you change to a new location in the world, a new music file should play.

Sometimes the old one just keeps going and the new one doesn't kick in.  Is music an object that can be unloaded?  Or is it just stop, pause, get whether it's playing and stop it if it's playing?  This is driving me nuts.  :  ) It mostly happens when you've been in a scene for only a few minutes and decide to hop to a new area in another section of the world.  The code is so simple I could post it but I don't think that would help. 

My music files are a little large--don't know if that has a bearing on this.  I will find a walkaround but I'd like to understand what's happening.  :  )

Thanks for any help. 
« Last Edit: March 12, 2009, 03:29:01 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Music Plays Too Long
« Reply #1 on: March 12, 2009, 12:38:06 PM »

With Music,
You can Play, Stop, Pause, Resume at any time in a scene, or while changing scenes.
You can use : Game.PlayMusic(someMusic, Loop or not Loop), or Game.PauseMusic .......
The same with MusicChannel.
You can also crossfade 2 music themes, or set the volume for the music.

Spyros

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #2 on: March 12, 2009, 02:42:04 PM »

Thanks.  I will have to do the changing of scenes a little differently--sometimes game seems to get confused.  Making a switch music method that might help.
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Chaos

  • supporter
  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 45
  • "WME rocks!"
    • View Profile
Re: Music Plays Too Long
« Reply #3 on: March 20, 2009, 05:11:45 AM »

Catacomber,I think you could easily add a "Game.StopMusic" at the start of each scene always before you set "Game.PlayMusic" so it will always stop the music that was playing on the previous scene,before playing the new one.Or if you want it to give it a more professional finished do not doubt of fading musical channels,you will find exactly how to do it on the WME documentation.

Also don't forget that as birdline said you can play,pause,resume and control the music volume at anytime you need.Well,I hope that helps you a little,Bye!

Cheers :D
« Last Edit: March 20, 2009, 05:30:14 AM by Chaos »
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #4 on: March 20, 2009, 02:46:03 PM »

Thanks, I will try all of those.  :  )  It's only a problem in one area and should solve it.  Thanks a lot.
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #5 on: March 21, 2009, 04:20:49 AM »

This is still a touchy problem for me as Game.StopMusic(); before Game.PlayMusic(); does not always work for some reason.  Am trying to figure out why. My music files are large.  Don't know if that has anything to do with it. 
« Last Edit: March 21, 2009, 04:22:32 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Chaos

  • supporter
  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 45
  • "WME rocks!"
    • View Profile
Re: Music Plays Too Long
« Reply #6 on: March 21, 2009, 06:42:54 AM »

That's strange because how large the music files are shouldn't really be a problem.

Just imagine that you have a music file that last 90 minutes and you started it with Game.PlayMusic,as soon as you go to the other scene,doesn't matter when,if you set it to stop before playing the new one it should work perfectly.(Obviously this should be at the start of the new scene's script)

My guess is that maybe the file adress that you linked to when you use the StopMusic maybe is not right.(remember that it should be the exactly the same file you started on the last scene).Or perhaps you should try using Game.StopMusic in the script that send you to the next scene(wheter clicking on a hotspot or an exit)on the line before Game.ChangeScene.Good luck and hope you manage to figure it out!

Bye! ::wave   
« Last Edit: March 21, 2009, 06:59:49 AM by Chaos »
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #7 on: March 22, 2009, 04:14:17 AM »

It's a little more complex as I have the same music playing in various scenes in a section and I don't want to have to restart the music each time you go from scene to scene in a section.  Would like it to play consistently from scene to scene in a given section without stopping or restarting. 

Am trying to work it out.  Thanks for your help.  It's much appreciated.
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Music Plays Too Long
« Reply #8 on: March 22, 2009, 01:04:04 PM »

If you want the music to continue from one scene to another, you don't have to do anything.
Once the music starts, it will play always (until you stop it).

If you want to temporary stop the music and start again from the same point (not from beginning),
you must use Game.PauseMusic() and then Game.ResumeMusic()

Spyros

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #9 on: March 23, 2009, 05:31:56 AM »

The problem is that I have many scenes that make up an area.  But you can go to these scenes from many other areas on a map. So sometimes 2 musics are playing because the game gets confused as it enters a new area on the map from a scene that was playing the music for the old scene/area.  It's complicated.  It should be simple but it's not -- at least not so far.  I've tried a lot of things including making a method to switch music.  Thanks, Birdline. Could you email me (catacomber@gmail.com) your email so I could send you a link for the game and you could take a look? You seem to have the music aspect nailed down.  ;  )
« Last Edit: March 23, 2009, 05:35:30 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Music Plays Too Long
« Reply #10 on: March 23, 2009, 07:49:03 AM »

You could use something like that (in each scene):

Code: WME Script
  1. if (Game.IsMusicPlaying() && Game.GetMusic() != "music\TheMusicSouldPlayHere.ogg") //If a music is playing and it isn't the right music for this scene
  2.         {
  3.         Game.PlayMusicChannel(1, "music\TheMusicSouldPlayHere.ogg"); //Load the new music in channel 1
  4.         Game.MusicCrossfade(0, 1, 1000); //Crossfade the new music with the old one
  5.         }
  6. else if (!Game.IsMusicPlaying()) Game.PlayMusic("music\TheMusicSouldPlayHere.ogg", true);
  7.  
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #11 on: March 23, 2009, 02:35:17 PM »

Thanks, Azrael, I will give that a try.
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Music Plays Too Long
« Reply #12 on: March 23, 2009, 08:39:31 PM »

If it's what you need it shouldn't be too difficult to create a function or a method too. The only part that should change is the path, and name, of the music file ;)
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #13 on: March 23, 2009, 08:52:46 PM »

Thanks, I have a Switch Music function that can be adapted. 
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Music Plays Too Long
« Reply #14 on: March 26, 2009, 03:44:43 AM »

Thanks, Azrael and Birdline---have this nailed down now--no more problems.   ::beer   Cheers.  :  )
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
Pages: [1] 2  All
 

Page created in 0.051 seconds with 21 queries.