[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] mixer.music in runtime
I've uploaded a minimal app that has the problem.
http://p4.hostingprod.com/@mousechief.com/musicFailSetup.exe
Here's the two relevant files:
------------------------------------- audio py
import pygame,os
musicNames = [];
#soundNames = ["sangria","sonar","drop","badswap","chaching","wall"];
soundNames = [];
soundLib = {};
mixer = music = None; #Hogari_Hisaaki-Yasuko_Yamano-Beagle.ogg
nextMusic = 0;
musicVolume = 1.0; #0.4;
musicFlag = True;
lastSound = "";
lastSndTime = 0;
loopSound = None;
def InitSounds():
global mixer, music, musicNames;
#try:
import pygame.mixer as pymix
mixer = pymix;
import pygame.mixer_music
music = pymix.music;
#except (ImportError, pygame.error):
# return;
tp = os.path.join('data','music');
tl = os.listdir(tp);
for fname in tl:
if (fname[-4] == '.'):
musicNames.append(fname);
music.set_volume(musicVolume);
PlayMusic();
while music.get_busy():
pass
pass
def PlayMusic(name, loopCount=1):
if (not music or not musicFlag): return;
#check music loop preference if loop: loop = -1;
loop = loopCount;
if music.get_busy():
#we really should fade out nicely and
#wait for the end music event, for now, CUT
music.stop();
fullname = os.path.join('data', 'music', name);
if (os.access(fullname,os.F_OK)):
music.load(fullname);
else:
fullname = os.path.join('data', 'sounds', name);
music.load(fullname);
music.play(loop);
return;
------------------------------------- setup.py
# A setup script showing how to extend py2exe.
#
# In this case, the py2exe command is subclassed to create an installation
# script for InnoSetup, which can be compiled with the InnoSetup compiler
# to a single file windows installer.
#
# By default, the installer will be created as dist\Output\setup.exe.
from distutils.core import setup
import py2exe
import sys
import shutil
################################################################
# arguments for the setup() call
brigiton = dict(
script = "main.py",
dest_base = r"prog\brigiton",
icon_resources = [(1,"DHSGiT.ico")])
zipfile = r"lib\shardlib"
options = {"py2exe": {"compressed": 0,
"optimize": 2}, }
#dataList = []; #glob.glob("data\\*");
#scan data folder for files and append in form "data\file
################################################################
import os
class InnoScript:
def __init__(self,
name,
lib_dir,
dist_dir,
windows_exe_files = [],
lib_files = [],
data_files = [],
version = "1.0.2.0"): #another one down below.
self.lib_dir = lib_dir
self.dist_dir = dist_dir
if not self.dist_dir[-1] in "\\/":
self.dist_dir += "\\"
self.name = name
self.version = version
self.windows_exe_files = [self.chop(p) for p in windows_exe_files]
self.lib_files = [self.chop(p) for p in lib_files]
def chop(self, pathname):
assert pathname.startswith(self.dist_dir)
return pathname[len(self.dist_dir):]
def create(self, pathname="dist\\brigiton.iss"):
self.pathname = pathname
ofi = self.file = open(pathname, "w")
print >> ofi, "; WARNING: This script has been created by py2exe. Changes to this script"
print >> ofi, "; will be overwritten the next time py2exe is run!"
print >> ofi, r"[Setup]"
print >> ofi, r"AppName=%s" % self.name
print >> ofi, r"AppVerName=%s %s" % (self.name, self.version)
print >> ofi, r"DefaultDirName={pf}\%s" % self.name
print >> ofi, r"DefaultGroupName=%s" % self.name
print >> ofi
print >> ofi, r"[Dirs]"
print >> ofi, r'Name: "{app}\prog\data"'
print >> ofi, r'Name: "{app}\prog\data\music"'
print >> ofi
print >> ofi, r"[Files]"
print >> ofi, r'Source: "prog\data\music\*"; DestDir: "{app}\prog\data\music"; Flags:
ignoreversion'
print >> ofi, r'Source: "prog\msvcr71.dll"; DestDir: "{app}\prog"; Flags: ignoreversion'
#print >> ofi, r'Source: "prog\libpng12-0.dll"; DestDir: "{app}\prog"; Flags:
ignoreversion'
#print >> ofi, r'Source: "prog\jpeg.dll"; DestDir: "{app}\prog"; Flags: ignoreversion'
#print >> ofi, r'Source: "prog\libvorbisfile-3.dll"; DestDir: "{app}\prog"; Flags:
ignoreversion'
#print >> ofi, r'Source: "prog\libogg-0.dll"; DestDir: "{app}\prog"; Flags: ignoreversion'
#print >> ofi, r'Source: "prog\libvorbis-0.dll"; DestDir: "{app}\prog"; Flags:
ignoreversion'
print >> ofi, r'Source: "prog\libfreetype-6.dll"; DestDir: "{app}\lib"; Flags:
ignoreversion'
#print >> ofi, r'Source: "prog\zlib1.dll"; DestDir: "{app}\lib"; Flags: ignoreversion'
for path in self.windows_exe_files + self.lib_files:
print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags: ignoreversion' % (path,
os.path.dirname(path))
print >> ofi
print >> ofi, r"[Icons]"
for path in self.windows_exe_files:
print >> ofi, r'Name: "{group}\%s"; Filename: "{app}\%s"' % \
(self.name, path)
print >> ofi, 'Name: "{group}\Uninstall %s"; Filename: "{uninstallexe}"' % self.name
def compile(self):
try:
import ctypes
except ImportError:
try:
import win32api
except ImportError:
import os
os.startfile(self.pathname)
else:
print "Ok, using win32api."
win32api.ShellExecute(0, "compile",
self.pathname,
None,
None,
0)
else:
print "Cool, you have ctypes installed."
res = ctypes.windll.shell32.ShellExecuteA(0, "compile",
self.pathname,
None,
None,
0)
if res < 32:
raise RuntimeError, "ShellExecute failed, error %d" % res
################################################################
from py2exe.build_exe import py2exe
class build_installer(py2exe):
# This class first builds the exe file(s), then creates a Windows installer.
# You need InnoSetup for it.
def run(self):
# First, let py2exe do it's work.
py2exe.run(self)
lib_dir = self.lib_dir
dist_dir = self.dist_dir
# create the Installer, using the files py2exe has created.
script = InnoScript("DangerousHSGirls",
lib_dir,
dist_dir,
self.windows_exe_files,
self.lib_files)
print "*** creating the inno setup script***"
script.create()
print "*** compiling the inno setup script***"
script.compile()
# Note: By default the final setup.exe will be in an Output subdirectory.
################################################################
setup(
options = options,
version = "1.0.2.0", #last digit for Windows increments between Mac increments
description = "py2exe script",
name = "Dangerous HS Girls in Trouble!",
# The lib directory contains everything except the executables and the python dll.
zipfile = zipfile,
windows = [brigiton],
# use out build_installer class as extended py2exe build command
cmdclass = {"py2exe": build_installer},
#data_files = [("prog\data", [])],
)
--- Keith Nemitz <musenik@xxxxxxxxx> wrote:
>
> I've started with fresh XP Sp2 installs on both VMWare and Parallels. Installed only what was
> necessary:
>
> Python, pygame, numeric, py2exe.
>
> As per earlier suggestion, I uninstalled py2exe 0.6.6 and installed 0.6.5.
>
> I don't think it's an install issue.
>
>
>
>
> --- René Dudfield <renesd@xxxxxxxxx> wrote:
>
> > ah,
> >
> > Have you tried uninstalling (maybe manually deleting) pygame, py2exe
> > etc then installing again?
> >
> > Maybe there's some problem with that...
> >
> >
> >
> > On Wed, May 21, 2008 at 9:31 AM, Keith Nemitz <musenik@xxxxxxxxx> wrote:
> > > Yep,
> > >
> > > It's in Program Files/(AppFolder)/lib.
> > >
> > >
> > >
> > >
> > > --- René Dudfield <renesd@xxxxxxxxx> wrote:
> > >
> > >> hi,
> > >>
> > >> Do you have the smpeg dll copied in there?
> > >>
> > >> cu,
> > >>
> > >>
> > >> On Wed, May 21, 2008 at 7:58 AM, Keith Nemitz <musenik@xxxxxxxxx> wrote:
> > >> > I get the following:
> > >> >
> > >> > AttributeError: 'module' object has no attribute 'mixer_music'
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > --- Brian Fisher <brian@xxxxxxxxxxxxxxxxxxx> wrote:
> > >> >
> > >> >> I guess that means it imports correctly, but somehow fails to get bound?
> > >> >>
> > >> >> I don't suppose you can access the functionality you need through
> > >> >> mixer_music, can you?
> > >> >>
> > >> >> In other words, what happens if you change the first failing
> > >> >> pygame.mixer.music.whatever line to pygame.mixer_music.whatever? (after the
> > >> >> import, of course)
> > >> >>
> > >> >> On Tue, May 20, 2008 at 11:17 AM, Keith Nemitz <musenik@xxxxxxxxx> wrote:
> > >> >>
> > >> >> > I put your import line right above the failing line, but got exactly the
> > >> >> > same results. I even
> > >> >> > removed the try/exception block.
> > >> >> >
> > >> >> >
> > >> >>
> > >> >
> > >> >
> > >>
> > >
> > >
> >
>
>