Commit 1d16ebff authored by Jason Simmons's avatar Jason Simmons

Merge pull request #959 from jason-simmons/sound_track_pause

Pause and resume of all tracks in SoundTrackPlayer
parents 247dc72b 8c45c949
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
library flutter_sprites; library flutter_sprites;
import 'dart:async'; import 'dart:async';
import 'dart:collection';
import 'dart:convert'; import 'dart:convert';
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:typed_data'; import 'dart:typed_data';
......
...@@ -135,7 +135,7 @@ class SoundTrack { ...@@ -135,7 +135,7 @@ class SoundTrack {
SoundTrackPlayer _sharedSoundTrackPlayer; SoundTrackPlayer _sharedSoundTrackPlayer;
class SoundTrackPlayer { class SoundTrackPlayer {
List<SoundTrack> _soundTracks = <SoundTrack>[]; Set<SoundTrack> _soundTracks = new HashSet<SoundTrack>();
static sharedInstance() { static sharedInstance() {
if (_sharedSoundTrackPlayer == null) { if (_sharedSoundTrackPlayer == null) {
...@@ -175,15 +175,20 @@ class SoundTrackPlayer { ...@@ -175,15 +175,20 @@ class SoundTrackPlayer {
soundTrack._player.ptr.setVolume(volume); soundTrack._player.ptr.setVolume(volume);
soundTrack._player.ptr.seekTo((startTime * 1000.0).toInt()); soundTrack._player.ptr.seekTo((startTime * 1000.0).toInt());
soundTrack._player.ptr.start(); soundTrack._player.ptr.start();
_soundTracks.add(soundTrack);
} }
void stop(SoundTrack track) { void stop(SoundTrack track) {
track._player.ptr.pause(); track._player.ptr.pause();
} }
void stopAll() { void pauseAll() {
for (SoundTrack soundTrack in _soundTracks) { for (SoundTrack soundTrack in _soundTracks)
soundTrack._player.ptr.pause(); soundTrack._player.ptr.pause();
} }
void resumeAll() {
for (SoundTrack soundTrack in _soundTracks)
soundTrack._player.ptr.start();
} }
} }
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