Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4530e457
Commit
4530e457
authored
Aug 13, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unifies interfaces for SoundTrackPlayer and SoundEffectPlayer
parent
a750da56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
27 deletions
+8
-27
sound.dart
examples/game/lib/sound.dart
+8
-27
No files found.
examples/game/lib/sound.dart
View file @
4530e457
...
...
@@ -21,7 +21,6 @@ class SoundEffect {
class
SoundEffectStream
{
SoundEffectStream
(
this
.
sound
,
this
.
tag
,
this
.
loop
,
this
.
volume
,
this
.
pitch
,
...
...
@@ -36,7 +35,6 @@ class SoundEffectStream {
double
volume
=
1.0
;
double
pitch
=
1.0
;
double
pan
=
0.0
;
Object
tag
;
// TODO: Implement completion callback. On completion, sounds should
// also be removed from the list of playing sounds.
...
...
@@ -62,7 +60,7 @@ class SoundEffectPlayer {
}
MediaServiceProxy
_mediaService
;
List
<
SoundEffectStream
>
_
playingSound
s
=
[];
List
<
SoundEffectStream
>
_
soundEffectStream
s
=
[];
// TODO: This should no longer be needed when moving to SoundPool backing
Map
<
SoundEffect
,
MediaPlayerProxy
>
_mediaPlayers
=
{};
...
...
@@ -87,8 +85,7 @@ class SoundEffectPlayer {
SoundEffectStream
play
(
SoundEffect
sound
,
[
Object
tag
,
bool
loop
=
false
,
[
bool
loop
=
false
,
double
volume
=
1.0
,
double
pitch
=
1.0
,
double
pan
=
0.0
,
...
...
@@ -97,7 +94,6 @@ class SoundEffectPlayer {
// Create new PlayingSound object
SoundEffectStream
playingSound
=
new
SoundEffectStream
(
sound
,
tag
,
loop
,
volume
,
pitch
,
...
...
@@ -117,7 +113,7 @@ class SoundEffectPlayer {
playingSound
.
_player
.
ptr
.
start
();
});
_
playingSound
s
.
add
(
playingSound
);
_
soundEffectStream
s
.
add
(
playingSound
);
_mediaPlayers
[
sound
]
=
playingSound
.
_player
;
}
else
{
// Reuse player
...
...
@@ -129,31 +125,16 @@ class SoundEffectPlayer {
return
playingSound
;
}
void
stop
(
Object
tag
)
{
for
(
int
i
=
_playingSounds
.
length
;
i
>=
0
;
i
--)
{
SoundEffectStream
playingSound
=
_playingSounds
[
i
];
if
(
playingSound
.
tag
==
tag
)
{
playingSound
.
_player
.
ptr
.
pause
();
_playingSounds
.
removeAt
(
i
);
}
}
}
List
<
SoundEffectStream
>
playingSoundsForTag
(
Object
tag
)
{
List
<
SoundEffectStream
>
list
=
[];
for
(
SoundEffectStream
playingSound
in
_playingSounds
)
{
if
(
playingSound
.
tag
==
tag
)
{
list
.
add
(
playingSound
);
}
}
return
list
;
void
stop
(
SoundEffectStream
stream
)
{
stream
.
_player
.
ptr
.
pause
();
_soundEffectStreams
.
remove
(
stream
);
}
void
stopAll
()
{
for
(
SoundEffectStream
playingSound
in
_
playingSound
s
)
{
for
(
SoundEffectStream
playingSound
in
_
soundEffectStream
s
)
{
playingSound
.
_player
.
ptr
.
pause
();
}
_
playingSound
s
=
[];
_
soundEffectStream
s
=
[];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment