mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 04:20:07 +01:00
Add wx.adv.Sound
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
1
TODO.txt
1
TODO.txt
@@ -127,7 +127,6 @@ other dev stuff
|
||||
* axbase (ActiveX. Need to figure out best ways to do MSW-only items...)
|
||||
* check that all items in _functions.i and _misc.i have been wrapped
|
||||
* joystick
|
||||
* sound
|
||||
* mimetype
|
||||
* power
|
||||
* overlay
|
||||
|
||||
@@ -34,6 +34,7 @@ INCLUDES = [
|
||||
'hyperlink',
|
||||
'tipdlg',
|
||||
'taskbar',
|
||||
'sound',
|
||||
|
||||
|
||||
# TODOs -
|
||||
@@ -49,7 +50,6 @@ INCLUDES = [
|
||||
#'odcombo',
|
||||
#'richtooltip',
|
||||
#'sashwin',
|
||||
#'sound',
|
||||
#'splash',
|
||||
#'timectrl',
|
||||
#'treelist',
|
||||
|
||||
75
etg/sound.py
Normal file
75
etg/sound.py
Normal file
@@ -0,0 +1,75 @@
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: etg/sound.py
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 15-May-2012
|
||||
# Copyright: (c) 2012 by Total Control Software
|
||||
# License: wxWindows License
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
import etgtools
|
||||
import etgtools.tweaker_tools as tools
|
||||
|
||||
PACKAGE = "wx"
|
||||
MODULE = "_adv"
|
||||
NAME = "sound" # Base name of the file to generate to for this script
|
||||
DOCSTRING = ""
|
||||
|
||||
# The classes and/or the basename of the Doxygen XML files to be processed by
|
||||
# this script.
|
||||
ITEMS = [ "wxSound",
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def run():
|
||||
# Parse the XML file(s) building a collection of Extractor objects
|
||||
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
|
||||
etgtools.parseDoxyXML(module, ITEMS)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# Tweak the parsed meta objects in the module object as needed for
|
||||
# customizing the generated code and docstrings.
|
||||
|
||||
module.addHeaderCode('#include <wx/sound.h>')
|
||||
module.addHeaderCode('#include "wxpybuffer.h"')
|
||||
|
||||
c = module.find('wxSound')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
c.addPrivateCopyCtor()
|
||||
c.addPublic()
|
||||
|
||||
c.find('wxSound').findOverload('data').ignore()
|
||||
#c.addCppCtor_sip('(wxPyBuffer* data)',
|
||||
# useDerivedName=True,
|
||||
# doc="Create a sound object from data in a memory buffer in WAV format.",
|
||||
# body="""\
|
||||
# sipCpp = new sipwxSound();
|
||||
# sipCpp->Create((size_t)data->m_len, data->m_ptr);
|
||||
# """)
|
||||
|
||||
|
||||
c.find('Create').findOverload('data').ignore()
|
||||
c.addCppMethod('bool', 'CreateFromData', '(wxPyBuffer* data)',
|
||||
doc="Create a sound object from data in a memory buffer in WAV format.",
|
||||
body="return self->Create((size_t)data->m_len, data->m_ptr);")
|
||||
|
||||
|
||||
c.find('wxSound.isResource').ignore()
|
||||
c.find('Create.isResource').ignore()
|
||||
|
||||
c.addCppMethod('int', '__nonzero__', '()', """\
|
||||
return self->IsOk();
|
||||
""")
|
||||
|
||||
c.find('Play').renameOverload('filename', 'PlaySound')
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
BIN
unittests/sound.wav
Executable file
BIN
unittests/sound.wav
Executable file
Binary file not shown.
38
unittests/test_sound.py
Normal file
38
unittests/test_sound.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import wx.adv
|
||||
import sys, os
|
||||
|
||||
wavFile = os.path.join(os.path.dirname(__file__), 'sound.wav')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class sound_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_sound1(self):
|
||||
wx.adv.SOUND_SYNC
|
||||
wx.adv.SOUND_ASYNC
|
||||
wx.adv.SOUND_LOOP
|
||||
|
||||
def test_sound2(self):
|
||||
sound = wx.adv.Sound(wavFile)
|
||||
self.assertTrue(sound.IsOk())
|
||||
rv = sound.Play(wx.adv.SOUND_SYNC)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'darwin', 'CreateFromBuffer not implemented on Mac')
|
||||
def test_sound3(self):
|
||||
sound = wx.adv.Sound()
|
||||
self.assertTrue(not sound.IsOk())
|
||||
data = open(wavFile, 'rb').read()
|
||||
sound.CreateFromData(data)
|
||||
self.assertTrue(sound.IsOk())
|
||||
rv = sound.Play(wx.adv.SOUND_SYNC)
|
||||
|
||||
def test_sound4(self):
|
||||
rv = wx.adv.Sound.PlaySound(wavFile, wx.adv.SOUND_SYNC)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user