A python (or plugin) request


(Pooba) #1

I would do this myself, but i have absolutely no knowledge of how to write python or make plugins, plus i’m lazy :stuck_out_tongue: .

I was just wondering if any of you could make a script or plugin to play mp3 type files in the gamengine(or midi’s, at least that would be a step up). Currently the gameengine only supports .wav files, and they have good quality but are WAY to big to be used in a game.

If you can help us (us being everyone who does game stuff w/ blender) we would be VERY thankful.

Thanx,
Pooba


(asdf_46) #2

Hey Pooba this shouldent be too big of a deal if you use pygame. I think it uses mp3 and at the very least it should use ogg vorbis. I will work on a script tonight. If anyone is intrested I am on MSN as [email protected]. asdf_46


(asdf_46) #3

!!!Works with .mp3 and .ogg !!!

Ok, I’ve got a script, or several scripts that will do it. The catch is that you need pygame and to have pygame you will need to have python. This all has to be installed with the correct set path options and there has the be an extra one to point to the pygame directory. That is the hard part. The scripts themselves are quite simple.

To use them just type them out in the text window and set the controller to python and set the script.

#To load music
import pygame.mixer
pygame.mixer.init()
pygame.mixer.music.load(“Your music here.ogg”)

#To play music
import pygame.mixer
pygame.mixer.music.play()

#To stop it
import pygame.mixer
pygame.mixer.music.stop()

#To pause it
import pygame.mixer
pygame.mixer.music.pause() #To unpause change just add un to pause

#To fade out
import pygame.mixer
pygame.mixer.music.fadeout(Time in milliseconds)

#Volume up
import pygame.mixer
from pygame.mixer import *
vol = music.get_volume()
vol = vol + 1 #Subtract to decrease volume
music.set_volume(vol)

There you have it. I will send anyone the sample file if you e-mail me. Hopefully I will soon have a web site I can post this stuff on. asdf_46


(Pooba) #4

Hmm, what the heck is a .ogg file? Never heard of it.


(asdf_46) #5

Ogg vorbis is like mp3 only opensource and better quality. Check it out at www.vorbis.com. asdf_46


(asdf_46) #6

Sorry about not knowing this sooner, but mp3’s work fine with the script. asdf_46