File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ void AudioPlayer::Init()
33
33
success = _decoder->Seek (_onLoadPositionMs) == _onLoadPositionMs;
34
34
else
35
35
success = _decoder->Open (_onLoadPositionMs);
36
+ _source->SetPlaybackPosMs (_decoder->GetPositionMs ());
36
37
_playState = success ? _onLoadPlayState : PlayStateError;
37
38
if (_playState == PlayStatePlaying)
38
39
_source->Play ();
@@ -123,6 +124,7 @@ void AudioPlayer::Seek(float pos_ms)
123
124
{
124
125
case PlayStateInitial:
125
126
_onLoadPositionMs = pos_ms;
127
+ Init (); // make sure the decoder opens and seeks, update posMs
126
128
break ;
127
129
case PlayStatePlaying:
128
130
case PlayStatePaused:
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ int SoundClip::play()
57
57
return true ;
58
58
}
59
59
60
+ int SoundClip::play_from (int position)
61
+ {
62
+ seek (position);
63
+ return play ();
64
+ }
65
+
60
66
void SoundClip::pause ()
61
67
{
62
68
if (!is_ready ())
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class SoundClip final
55
55
int maximumPossibleDistanceAway;
56
56
57
57
int play ();
58
+ int play_from (int position);
58
59
void pause ();
59
60
void resume ();
60
61
// Seeks to the position, where pos units depend on the audio type
@@ -68,12 +69,6 @@ class SoundClip final
68
69
// Returns if the clip is still playing, otherwise it's finished
69
70
bool update ();
70
71
71
- inline int play_from (int position)
72
- {
73
- seek (position);
74
- return play ();
75
- }
76
-
77
72
// Gets if the clip is valid (playing or ready to play)
78
73
inline bool is_ready () const
79
74
{
You can’t perform that action at this time.
0 commit comments