メニュー

pygame.cdrom

音楽CDを操作するのに使うpygameモジュールです

このcdromモジュールでパソコンのCD/DVDドライブの制御を行えます。音楽CDの再生も行えます。このモジュールを使用する際は事前に初期化をしなければいけません。pygame.cdrom.CD命令で作成した各CDオブジェクトでは一つのCDドライブの操作を行え、CDオブジェクトの命令を使用する際も個々に初期化を行わなければいけません。

pygame module for audio cdrom control

The cdrom module manages the CD and DVD drives on a computer. It can also control the playback of audio cd's. This module needs to be initialized before it can do anything. Each CD object you create represents a cdrom drive and must also be initialized individually before it can do most things.


pygame.cdrom.init

cdromモジュールを初期化します。
pygame.cdrom.init(): return None

cdromモジュールを初期化します。この命令ではパソコンに接続された全てのCDドライブを調べます。cdromモジュールの他の命令を実行する前には初期化を行っていなければなりません。 この命令はpygame.init命令を実行したときに自動的に実行されます。

この命令を複数回実行しても特に問題ありません。

initialize the cdrom module
pygame.cdrom.init(): return None

Initialize the cdrom module. This will scan the system for all CD devices. The module must be initialized before any other functions will work. This automatically happens when you call pygame.init - initialize all imported pygame modules.

It is safe to call this function more than once.


pygame.cdrom.quit

cdromモジュールの初期化を解除します。
pygame.cdrom.quit(): return None

cdromモジュールの初期化を解除します。この命令を実行すると作成済みのCDオブジェクトも使用できなくなります。

この命令を複数回実行しても特に問題ありません。

uninitialize the cdrom module
pygame.cdrom.quit(): return None

Uninitialize the cdrom module. After you call this any existing CD objects will no longer work.

It is safe to call this function more than once.


pygame.cdrom.get_init

cdromモジュールが初期化済みならtrueが取得されます。
pygame.cdrom.get_init(): return bool

cdromモジュールが初期化済みかどうか調べます。個々のCDドライブの初期化は別途個別に行われているので、CD.init命令で行った初期化状態までは調べられません。

true if the cdrom module is initialized
pygame.cdrom.get_init(): return bool

Test if the cdrom module is initialized or not. This is different than the CD.init - initialize a cdrom drive for use since each drive must also be initialized individually.


pygame.cdrom.get_count

パソコンに接続されているCDドライブの数を取得します。
pygame.cdrom.get_count(): return count

パソコンに接続されているCDドライブの数を戻り値として返します。pygame.cdrom.CD命令でCDオブジェクトを作成する際にはCDドライブを識別するための定数を設定するのですが、その定数は個々で取得される数より小さい値でなければなりません。パソコンにCDドライブが付いていない場合は0が戻り値として返されます。

number of cd drives on the system
pygame.cdrom.get_count(): return count

Return the number of cd drives on the system. When you create CD objects you need to pass an integer id that must be lower than this count. The count will be 0 if there are no drives on the system.


pygame.cdrom.CD

cdromドライブを操作するためのクラス。
pygame.cdrom.CD(id): return CD
  • CD.init - cdromドライブを使用するために初期化を行います。
  • CD.quit - cdromドライブを使用するために初期化を解除します。
  • CD.get_init - cdドライブが初期化されている場合はtrueが取得されます。
  • CD.play - 音楽の再生を開始します。
  • CD.stop - 音楽の再生を終了します。
  • CD.pause - 音楽の再生を一時停止します。
  • CD.resume - 音楽再生の一時停止を解除します。
  • CD.eject - CDトレイを開きます。
  • CD.get_id - cdromドライブの識別番号。
  • CD.get_name - cdromドライブのシステム名
  • CD.get_busy - CDドライブが再生中の場合はtrueが取得されます。
  • CD.get_paused - CDドライブが一時停止状態の場合はtrueが取得されます。
  • CD.get_current - 現在の音楽再生位置
  • CD.get_empty - cdromがドライブにセットされている場合はFalseが取得されます。
  • CD.get_numtracks - cdromの音楽トラック数
  • CD.get_track_audio - cdromに音楽データトラックがある場合はtrueが取得されます。
  • CD.get_all - 全てのトラック情報を取得します。
  • CD.get_track_start - cdromの各トラックの再生開始時間
  • CD.get_track_length - cdromの各トラックの再生時間

パソコンに接続されているCDドライブ一つにつき一つのCDオブジェクトを作成できます。pygame.cdrom.get_count命令を使用すればパソコンにいくつのCDドライブが接続されているかが分かります。id引数にはCDドライブの識別番号を設定します。識別番号は、パソコンに接続されているCDドライブの数に合わせた0から始まる整数となります。

CDオブジェクトが初期化されていない状態ではCD.get_id命令とCD.get_name命令しか実行できません。

一つのCDドライブに対して複数のCDオブジェクトを作成しても特に問題はなく、各オブジェクトを通じて正常にCDドライブの操作を行えます。

class to manage a cdrom drive
pygame.cdrom.CD(id): return CD

You can create a CD object for each cdrom on the system. Use pygame.cdrom.get_count - number of cd drives on the system to determine how many drives actually exist. The id argument is an integer of the drive, starting at zero.

The CD object is not initialized, you can only call CD.get_id - the index of the cdrom drive and CD.get_name - the system name of the cdrom drive on an uninitialized drive.

It is safe to create multiple CD objects for the same drive, they will all cooperate normally.


CD.init

cdromドライブを使用するために初期化を行います。
CD.init(): return None

cdromドライブを使用するために初期化を行います。他のpygameモジュールが初期化済みであっても、CD操作命令を実行するにはドライブの初期化が行われていなければなりません。

ドライブを初期化する間、プログラムが少し停止する場合があります。プログラムを1~2秒たりとも停止させたくない場合はCD.init命令を使うのは避けてください。

initialize a cdrom drive for use
CD.init(): return None

Initialize the cdrom drive for use. The drive must be initialized for most CD methods to work. Even if the rest of pygame has been initialized.

There may be a brief pause while the drive is initialized. Avoid CD.init - initialize a cdrom drive for use if the program should not stop for a second or two.


CD.quit

cdromドライブを使用するために初期化を解除します。
CD.quit(): return None

ドライブを使用するために初期化を行います。しばらくCDドライブの操作を行わないのであれば、この命令を実行してください。

uninitialize a cdrom drive for use
CD.quit(): return None

Uninitialize a drive for use. Call this when your program will not be accessing the drive for awhile.


CD.get_init

cdドライブが初期化されている場合はtrueが取得されます。
CD.get_init(): return bool

CDROMドライブが初期化されているか調べます。個々のCDドライブの初期化は別途個別に行われているので、pygame.cdrom.init命令で行った初期化状態までは調べられません。

true if this cd device initialized
CD.get_init(): return bool

Test if this CDROM device is initialized. This is different than the pygame.cdrom.init - initialize the cdrom module since each drive must also be initialized individually.


CD.play

音楽の再生を開始します。
CD.play(track, start=None, end=None): return None

CDドライブにセットされている音楽CDを再生します。再生するトラックナンバーを指定する引数以外にも、再生の開始時間や終了時間も引数に設定することができます。開始・終了時間は秒単位で設定し、音楽の再生される範囲を制限することができます。

start引数を設定してend引数を設定しなかった場合、音楽はトラックの最後まで再生されます。 start引数を設定してend引数に'None'を設定した場合、音楽はディスクの最後まで再生されます。

再生するトラックを調べる方法についてはCD.get_numtracks命令やCD.get_track_audio命令を参照してください。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

start playing audio
CD.play(track, start=None, end=None): return None

Playback audio from an audio cdrom in the drive. Besides the track number argument, you can also pass a starting and ending time for playback. The start and end time are in seconds, and can limit the section of an audio track played.

If you pass a start time but no end, the audio will play to the end of the track. If you pass a start time and 'None' for the end time, the audio will play to the end of the entire disc.

See the CD.get_numtracks - the number of tracks on the cdrom and CD.get_track_audio - true if the cdrom track has audio data to find tracks to playback.

Note, track 0 is the first track on the CD. Track numbers start at zero.


CD.stop

音楽の再生を終了します。
CD.stop(): return None

cdromの音楽再生を終了します。現在の再生位置情報は失われます。CDドライブで音楽の再生が行われていない場合は、この命令を実行しても何も起こりません。

stop audio playback
CD.stop(): return None

Stops playback of audio from the cdrom. This will also lose the current playback position. This method does nothing if the drive isn't already playing audio.


CD.pause

音楽の再生を一時停止します。
CD.pause(): return None

CDの音楽再生を一時停止します。CD.resume命令を使用することで停止位置から再生を再開できます。 CDの音楽再生が行われていない場合は、この命令を実行しても何も起こりません。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

temporarily stop audio playback
CD.pause(): return None

Temporarily stop audio playback on the CD. The playback can be resumed at the same point with the CD.resume - unpause audio playback method. If the CD is not playing this method does nothing.

Note, track 0 is the first track on the CD. Track numbers start at zero.


CD.resume

音楽再生の一時停止を解除します。
CD.resume(): return None

CDの一時停止を解除します。CDが一時停止されていなかったり、既に再生が開始されている場合は、この命令を実行しても何も起こりません。

unpause audio playback
CD.resume(): return None

Unpause a paused CD. If the CD is not paused or already playing, this method does nothing.


CD.eject

CDトレイを開きます。
CD.eject(): return None

この命令でCDトレイを開くことができます。CDが再生中だったり一時停止状態だった場合、その再生は終了されます。

eject or open the cdrom drive
CD.eject(): return None

This will open the cdrom drive and eject the cdrom. If the drive is playing or paused it will be stopped.


CD.get_id

cdromドライブの識別番号。
CD.get_id(): return id

CDインスタンスの作成に使われる識別番号を戻り値として返します。CDインスタンスが初期化されていなくてもこの命令は実行することができます。

the index of the cdrom drive
CD.get_id(): return id

Returns the integer id that was used to create the CD instance. This method can work on an uninitialized CD.


CD.get_name

cdromドライブのシステム名
CD.get_name(): return name

ドライブの名前を文字列型の戻り値として返します。これはドライブを分かりやすく表すのに使用されるシステム名です。大抵はcdromドライブのドライブ文字か、機器名が取得されます。CDインスタンスが初期化されていなくてもこの命令は実行することができます。

the system name of the cdrom drive
CD.get_name(): return name

Return the string name of the drive. This is the system name used to represent the drive. It is often the drive letter or device name. This method can work on an uninitialized CD.


CD.get_busy

CDドライブが再生中の場合はtrueが取得されます。
CD.get_busy(): return bool

CDドライブが再生中の場合はTrueが戻り値として返ります。

true if the drive is playing audio
CD.get_busy(): return bool

Returns True if the drive busy playing back audio.


CD.get_paused

CDドライブが一時停止状態の場合はtrueが取得されます。
CD.get_paused(): return bool

CDドライブが一時停止状態の場合はTrueが戻り値として返ります。

true if the drive is paused
CD.get_paused(): return bool

Returns True if the drive is currently paused.


CD.get_current

現在の音楽再生位置
CD.get_current(): return track, seconds

現在再生しているトラックナンバーとトラック再生時間の二つを戻り値として返します。この命令は音楽が再生中か一時停止状態の時に実行できます。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

the current audio playback position
CD.get_current(): return track, seconds

Returns both the current track and time of that track. This method works when the drive is either playing or paused.

Note, track 0 is the first track on the CD. Track numbers start at zero.


CD.get_empty

cdromがドライブにセットされている場合はFalseが取得されます。
CD.get_empty(): return bool

音楽CDがドライブにセットされている場合はFalseが戻り値として返されます。ドライブに何もセットされていない場合はTrueが戻り値として返されます。

False if a cdrom is in the drive
CD.get_empty(): return bool

Return False if there is a cdrom currently in the drive. If the drive is empty this will return True.


CD.get_numtracks

cdromの音楽トラック数
CD.get_numtracks(): return count

ドライブにセットされた音楽CDのトラック数を戻り値として返します。CDがセットされていなかったり、CDに音楽トラックがない場合は0を戻り値として返します。

the number of tracks on the cdrom
CD.get_numtracks(): return count

Return the number of tracks on the cdrom in the drive. This will return zero of the drive is empty or has no tracks.


CD.get_track_audio

cdromに音楽データトラックがある場合はtrueが取得されます。
CD.get_track_audio(track): return bool

cdromに音楽データトラックがあるかどうかを確認します。またCD.num_tracks()命令やCD.get_all命令を使用することでより詳細なCDのトラック情報を確認することもできます。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

true if the cdrom track has audio data
CD.get_track_audio(track): return bool

Determine if a track on a cdrom contains audio data. You can also call CD.num_tracks() and CD.get_all - get all track information to determine more information about the cdrom.

Note, track 0 is the first track on the CD. Track numbers start at zero.


CD.get_all

全てのトラック情報を取得します。
CD.get_all(): return [(audio, start, end, lenth), ...]

cdromに記録された全てのトラック情報をリスト型の戻り値として取得します。各トラック情報には4つの値がタプル形式で入っています。audio値は、トラックに音楽データが記録されている場合にTrueとなります。start値・end値・length値は、秒単位の浮動小数点で表されます。start値とend値の時間位置については、cd全体を通した再生時間内での絶対位置となります。

get all track information
CD.get_all(): return [(audio, start, end, lenth), ...]

Return a list with information for every track on the cdrom. The information consists of a tuple with four values. The audio value is True if the track contains audio data. The start, end, and length values are floating point numbers in seconds. Start and end represent absolute times on the entire disc.


CD.get_track_start

cdromの各トラックの再生開始時間
CD.get_track_start(track): return seconds

指定したトラックの再生開始時間を、cd全体を通した再生時間内での絶対位置で取得します。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

start time of a cdrom track
CD.get_track_start(track): return seconds

Return the absolute time in seconds where at start of the cdrom track.

Note, track 0 is the first track on the CD. Track numbers start at zero.


CD.get_track_length

cdromの各トラックの再生時間
CD.get_track_length(track): return seconds

指定したトラックの再生時間を、秒単位の浮動小数点で取得します。

トラック0がCDの一番初めのトラックになるので注意してください。トラックナンバーは0から始まります。

length of a cdrom track
CD.get_track_length(track): return seconds

Return a floating point value in seconds of the length of the cdrom track.

Note, track 0 is the first track on the CD. Track numbers start at zero.