Inherits from PXEventDispatcher : NSObject
Declared in PXSoundChannel.h
PXSoundChannel.m

Overview

Represents a loaded and playing sound. Sound channels should never be initialized manually, but instead created via the [PXSound play] method.

Tasks

  •   soundTransform

    The transform of the sound.

    property
  •   position

    The current point in milliseconds of the playing sound.

    property
  •   isPlaying

    YES if the sound is playing, otherwise NO.

    property
  • – play

    If the sound is not already playing, it plays the sound from it’s current position.

  • – pause

    If the sound is not already paused, it pauses the sound at it’s current position.

  • – stop

    If the sound is not already stopped, it stops the sound and removes it permanently from the play list.

  • – rewind

    If the sound is not already rewound, it rewinds the sound moving it’s position back to 0 and continues playing if it were previously playing, or pause if it was previously paused. This does not reset the loops already done.

Properties

isPlaying

YES if the sound is playing, otherwise NO.

@property (nonatomic, readonly) BOOL isPlaying

Declared In

PXSoundChannel.h

position

The current point in milliseconds of the playing sound.

@property (nonatomic, readonly) unsigned position

Declared In

PXSoundChannel.h

soundTransform

The transform of the sound.

@property (nonatomic, copy) PXSoundTransform *soundTransform

Declared In

PXSoundChannel.h

Instance Methods

pause

If the sound is not already paused, it pauses the sound at it’s current position.

- (void)pause

Discussion

Example:

PXSound *sound = [PXSound soundWithContentsOfFile:@"sound.wav"];
PXSoundChannel *channel = [sound play];
// The sound is playing
[channel pause];
// The sound is paused

Declared In

PXSoundChannel.m

play

If the sound is not already playing, it plays the sound from it’s current position.

- (BOOL)play

Discussion

Example:

PXSound *sound = [PXSound soundWithContentsOfFile:@"sound.wav"];
PXSoundChannel *channel = [sound play];
// The sound is playing
[channel pause];
// The sound is paused
[channel play];
// The sound is playing

Declared In

PXSoundChannel.m

rewind

If the sound is not already rewound, it rewinds the sound moving it’s position back to 0 and continues playing if it were previously playing, or pause if it was previously paused. This does not reset the loops already done.

- (void)rewind

Discussion

Example:

PXSound *sound = [PXSound soundWithContentsOfFile:@"sound.wav"];
PXSoundChannel *channel = [sound play];
// The sound is playing
[channel rewind];
// The sound is rewinded and continues playing
[channel pause];
// The sound is paused
[channel rewind];
// The sound is rewinded and continues staying paused

Declared In

PXSoundChannel.m

stop

If the sound is not already stopped, it stops the sound and removes it permanently from the play list.

- (void)stop

Discussion

Example:

PXSound *sound = [PXSound soundWithContentsOfFile:@"sound.wav"];
PXSoundChannel *channel = [sound play];
// The sound is playing
[channel stop];
// The sound is stopped and wont play again

Declared In

PXSoundChannel.m