Commit fa82f1a6 authored by Viktor Lidholt's avatar Viktor Lidholt

Refactors names of sound effect classes

parent 68953122
...@@ -30,7 +30,7 @@ class GameDemoWorld extends NodeWithSize { ...@@ -30,7 +30,7 @@ class GameDemoWorld extends NodeWithSize {
SpriteSheet _spriteSheetUI; SpriteSheet _spriteSheetUI;
Map<String,SoundEffect> _sounds; Map<String,SoundEffect> _sounds;
SoundPool _soundPool = SoundPool.sharedInstance(); SoundEffectPlayer _soundPool = SoundEffectPlayer.sharedInstance();
Navigator _navigator; Navigator _navigator;
......
...@@ -18,8 +18,8 @@ class SoundEffect { ...@@ -18,8 +18,8 @@ class SoundEffect {
Object _data; Object _data;
} }
class SoundStream { class SoundEffectStream {
SoundStream( SoundEffectStream(
this.sound, this.sound,
this.tag, this.tag,
this.loop, this.loop,
...@@ -45,29 +45,29 @@ class SoundStream { ...@@ -45,29 +45,29 @@ class SoundStream {
MediaPlayerProxy _player; MediaPlayerProxy _player;
} }
SoundPool _sharedSoundPool; SoundEffectPlayer _sharedSoundPool;
class SoundPool { class SoundEffectPlayer {
static SoundPool sharedInstance() { static SoundEffectPlayer sharedInstance() {
if (_sharedSoundPool == null) { if (_sharedSoundPool == null) {
_sharedSoundPool = new SoundPool(); _sharedSoundPool = new SoundEffectPlayer();
} }
return _sharedSoundPool; return _sharedSoundPool;
} }
SoundPool() { SoundEffectPlayer() {
_mediaService = new MediaServiceProxy.unbound(); _mediaService = new MediaServiceProxy.unbound();
shell.requestService(null, _mediaService); shell.requestService(null, _mediaService);
} }
MediaServiceProxy _mediaService; MediaServiceProxy _mediaService;
List<SoundStream> _playingSounds = []; List<SoundEffectStream> _playingSounds = [];
// TODO: This should no longer be needed when moving to SoundPool backing // TODO: This should no longer be needed when moving to SoundPool backing
Map<SoundEffect,MediaPlayerProxy> _mediaPlayers = {}; Map<SoundEffect,MediaPlayerProxy> _mediaPlayers = {};
Future _prepare(SoundStream playingSound) async { Future _prepare(SoundEffectStream playingSound) async {
await playingSound._player.ptr.prepare(playingSound.sound._data); await playingSound._player.ptr.prepare(playingSound.sound._data);
} }
...@@ -85,7 +85,7 @@ class SoundPool { ...@@ -85,7 +85,7 @@ class SoundPool {
// TODO: Add paused property (should pause playback of all sounds) // TODO: Add paused property (should pause playback of all sounds)
bool paused; bool paused;
SoundStream play( SoundEffectStream play(
SoundEffect sound, SoundEffect sound,
[Object tag, [Object tag,
bool loop = false, bool loop = false,
...@@ -95,7 +95,7 @@ class SoundPool { ...@@ -95,7 +95,7 @@ class SoundPool {
SoundCompleteCallback callback = null]) { SoundCompleteCallback callback = null]) {
// Create new PlayingSound object // Create new PlayingSound object
SoundStream playingSound = new SoundStream( SoundEffectStream playingSound = new SoundEffectStream(
sound, sound,
tag, tag,
loop, loop,
...@@ -131,7 +131,7 @@ class SoundPool { ...@@ -131,7 +131,7 @@ class SoundPool {
void stop(Object tag) { void stop(Object tag) {
for (int i = _playingSounds.length; i >= 0; i--) { for (int i = _playingSounds.length; i >= 0; i--) {
SoundStream playingSound = _playingSounds[i]; SoundEffectStream playingSound = _playingSounds[i];
if (playingSound.tag == tag) { if (playingSound.tag == tag) {
playingSound._player.ptr.pause(); playingSound._player.ptr.pause();
_playingSounds.removeAt(i); _playingSounds.removeAt(i);
...@@ -139,9 +139,9 @@ class SoundPool { ...@@ -139,9 +139,9 @@ class SoundPool {
} }
} }
List<SoundStream> playingSoundsForTag(Object tag) { List<SoundEffectStream> playingSoundsForTag(Object tag) {
List<SoundStream> list = []; List<SoundEffectStream> list = [];
for (SoundStream playingSound in _playingSounds) { for (SoundEffectStream playingSound in _playingSounds) {
if (playingSound.tag == tag) { if (playingSound.tag == tag) {
list.add(playingSound); list.add(playingSound);
} }
...@@ -150,7 +150,7 @@ class SoundPool { ...@@ -150,7 +150,7 @@ class SoundPool {
} }
void stopAll() { void stopAll() {
for (SoundStream playingSound in _playingSounds) { for (SoundEffectStream playingSound in _playingSounds) {
playingSound._player.ptr.pause(); playingSound._player.ptr.pause();
} }
_playingSounds = []; _playingSounds = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment