Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e600578a
Kaydet (Commit)
e600578a
authored
Şub 04, 1999
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add winsound -- by Toby Dickenson with permission.
üst
f9ffb03c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
0 deletions
+130
-0
config.c
PC/config.c
+2
-0
winsound.c
PC/winsound.c
+128
-0
No files found.
PC/config.c
Dosyayı görüntüle @
e600578a
...
...
@@ -63,6 +63,7 @@ extern void initcPickle();
extern
void
initpcre
();
#ifdef WIN32
extern
void
initmsvcrt
();
extern
void
initwinsound
();
extern
void
init_locale
();
#endif
...
...
@@ -106,6 +107,7 @@ struct _inittab _PyImport_Inittab[] = {
{
"pcre"
,
initpcre
},
#ifdef WIN32
{
"msvcrt"
,
initmsvcrt
},
{
"winsound"
,
initwinsound
},
{
"_locale"
,
init_locale
},
#endif
...
...
PC/winsound.c
0 → 100644
Dosyayı görüntüle @
e600578a
/* Author: Toby Dickenson <htrd90@zepler.org>
*
* Copyright (c) 1999 Toby Dickenson
*
* Permission to use this software in any way is granted without
* fee, provided that the copyright notice above appears in all
* copies. This software is provided "as is" without any warranty.
*/
/* Modified by Guido van Rossum */
/* Example:
import winsound
import time
# Play wav file
winsound.PlaySound('c:/windows/media/Chord.wav', winsound.SND_FILENAME)
# Play sound from control panel settings
winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
# Play wav file from memory
data=open('c:/windows/media/Chimes.wav',"rb").read()
winsound.PlaySound(data, winsound.SND_MEMORY)
# Start playing the first bit of wav file asynchronously
winsound.PlaySound('c:/windows/media/Chord.wav',
winsound.SND_FILENAME|winsound.SND_ASYNC)
# But dont let it go for too long...
time.sleep(0.1)
# ...Before stopping it
winsound.PlaySound(None, 0)
*/
#include <windows.h>
#include <mmsystem.h>
#include <Python.h>
static
char
sound_playsound_doc
[]
=
"PlaySound(sound, flags) - a wrapper around the Windows PlaySound API
\n
"
"
\n
"
"The sound argument can be a filename, data, or None.
\n
"
"For flag values, ored together, see module documentation.
\n
"
;
static
char
sound_module_doc
[]
=
"PlaySound(sound, flags) - play a sound
\n
"
"SND_FILENAME - sound is a wav file name
\n
"
"SND_ALIAS - sound is a control panel sound association name
\n
"
"SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC
\n
"
"SND_MEMORY - sound is a memory image of a wav file
\n
"
"SND_PURGE - stop all instances of the specified sound
\n
"
"SND_ASYNC - PlaySound returns immediately
\n
"
"SND_NODEFAULT - Do not play a default beep if the sound can not be found
\n
"
"SND_NOSTOP - Do not interrupt any sounds currently playing
\n
"
// Raising RuntimeError if needed
"SND_NOWAIT - Return immediately if the sound driver is busy
\n
"
// Without any errors
;
PyObject
*
sound_playsound
(
PyObject
*
s
,
PyObject
*
args
)
{
const
char
*
sound
;
int
flags
;
int
length
;
int
ok
;
if
(
!
PyArg_ParseTuple
(
args
,
"z#i:PlaySound"
,
&
sound
,
&
length
,
&
flags
))
{
return
NULL
;
}
if
(
flags
&
SND_ASYNC
&&
flags
&
SND_MEMORY
)
{
/* Sidestep reference counting headache; unfortunately this also
prevent SND_LOOP from memory. */
PyErr_SetString
(
PyExc_RuntimeError
,
"Cannot play asynchronously from memory"
);
return
NULL
;
}
Py_BEGIN_ALLOW_THREADS
ok
=
PlaySound
(
sound
,
NULL
,
flags
);
Py_END_ALLOW_THREADS
if
(
!
ok
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"Failed to play sound"
);
return
NULL
;
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
struct
PyMethodDef
sound_methods
[]
=
{
{
"PlaySound"
,
sound_playsound
,
1
,
sound_playsound_doc
},
{
NULL
,
NULL
}
};
static
void
add_define
(
PyObject
*
dict
,
const
char
*
key
,
long
value
)
{
PyObject
*
k
=
PyString_FromString
(
key
);
PyObject
*
v
=
PyLong_FromLong
(
value
);
if
(
v
&&
k
)
{
PyDict_SetItem
(
dict
,
k
,
v
);
}
Py_XDECREF
(
k
);
Py_XDECREF
(
v
);
}
#define ADD_DEFINE(tok) add_define(dict,#tok,tok)
DL_EXPORT
(
void
)
initwinsound
()
{
PyObject
*
module
=
Py_InitModule3
(
"winsound"
,
sound_methods
,
sound_module_doc
);
PyObject
*
dict
=
PyModule_GetDict
(
module
);
ADD_DEFINE
(
SND_ASYNC
);
ADD_DEFINE
(
SND_NODEFAULT
);
ADD_DEFINE
(
SND_NOSTOP
);
ADD_DEFINE
(
SND_NOWAIT
);
ADD_DEFINE
(
SND_ALIAS
);
ADD_DEFINE
(
SND_FILENAME
);
ADD_DEFINE
(
SND_MEMORY
);
ADD_DEFINE
(
SND_PURGE
);
ADD_DEFINE
(
SND_LOOP
);
ADD_DEFINE
(
SND_APPLICATION
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment