24 @
typedef HTMLAudioElement
29 - (void)sound:(
CPSound)aSound didFinishPlaying:(BOOL)finishedLoading;
59 BOOL _playRequestBeforeLoad;
60 HTMLAudioElement _audioTag;
63 unsigned _implementedDelegateMethods;
67 #pragma mark Initialization 71 if (
self = [super
init])
75 _audioTag = document.createElement(
"audio");
76 _audioTag.preload = YES;
77 _playRequestBeforeLoad = NO;
79 _audioTag.addEventListener(
"canplay",
function()
85 _audioTag.addEventListener(
"ended",
function()
91 _audioTag.addEventListener(
"error",
function()
107 - (id)initWithContentsOfFile:(
CPString)aFile byReference:(BOOL)byRef
109 if (
self = [
self init])
112 _audioTag.src = aFile;
124 - (id)initWithContentsOfURL:(
CPURL)aURL byReference:(BOOL)byRef
137 if (
self = [
self init])
148 #pragma mark Delegate methods 154 - (void)setDelegate:(
id)aDelegate
156 if (_delegate === aDelegate)
159 _delegate = aDelegate;
160 _implementedDelegateMethods = 0;
162 if ([_delegate respondsToSelector:
@selector(sound:didFinishPlaying:)])
167 #pragma mark Events listener 171 - (void)_soundDidload
175 if (_playRequestBeforeLoad)
177 _playRequestBeforeLoad = NO;
195 CPLog.error(
"Cannot load sound. Maybe the format of your sound is not compatible with your browser.");
200 #pragma mark Media controls 211 _playRequestBeforeLoad = YES;
237 _audioTag.currentTime = 0.0;
240 [
self _sendDelegateSoundDidFinishPlaying:YES];
286 return _audioTag.loop;
294 - (void)setLoops:(BOOL)shouldLoop
296 _audioTag.loop = shouldLoop;
306 return _audioTag.volume;
314 - (void)setVolume:(
double)aVolume
318 else if (aVolume < 0.0)
321 _audioTag.volume = aVolume;
325 #pragma mark Accessors 334 return _audioTag.duration;
356 - (void)_sendDelegateSoundDidFinishPlaying:(BOOL)finishedPlaying
361 [_delegate sound:self didFinishPlaying:finishedPlaying];
395 - (void)setDelegate:(
id)aValue
var CPSoundDelegate_sound_didFinishPlaying_
The main run loop for the application.
id initWithContentsOfFile:byReference:(CPString aFile, [byReference] BOOL byRef)
A Cappuccino wrapper for any data type.
CPRunLoop currentRunLoop()
FrameUpdater prototype stop
CPSoundLoadStateCanBePlayed
An immutable string (collection of characters).
CPString absoluteString()
CPSoundPlayBackStatePause
CPDate limitDateForMode:(CPString aMode)