@@ -29,6 +29,7 @@ export interface ICoreOptions {
2929 loadPlayerMode ?: typePlayerMode ;
3030 audioContext ?: AudioContext ;
3131 addAudioElementsToDom ?: boolean ;
32+ volumeTransitionTime ?: number ;
3233}
3334
3435export interface ISoundsQueueOptions {
@@ -112,6 +113,7 @@ export class PlayerCore {
112113 loadPlayerMode : PLAYER_MODE_AUDIO ,
113114 audioContext : null ,
114115 addAudioElementsToDom : false ,
116+ volumeTransitionTime : 100 ,
115117 } ;
116118
117119 const options = Object . assign ( { } , defaultOptions , playerOptions ) ;
@@ -158,6 +160,7 @@ export class PlayerCore {
158160 persistVolume : this . _options . persistVolume ,
159161 loadPlayerMode : this . _options . loadPlayerMode ,
160162 addAudioElementsToDom : this . _options . addAudioElementsToDom ,
163+ volumeTransitionTime : this . _options . volumeTransitionTime ,
161164 } ;
162165
163166 return audioOptions ;
@@ -313,7 +316,9 @@ export class PlayerCore {
313316
314317 if ( currentSound !== null ) {
315318
316- if ( ! isNaN ( currentSound . duration ) && ( soundPositionInSeconds > currentSound . duration ) ) {
319+ // round duration up as numbers are not integers
320+ // so sometimes it is a tiny bit above
321+ if ( ! isNaN ( currentSound . duration ) && ( soundPositionInSeconds > Math . ceil ( currentSound . duration ) ) ) {
317322 console . warn ( 'soundPositionInSeconds > sound duration' )
318323 }
319324
@@ -646,7 +651,9 @@ export class PlayerCore {
646651 sound . sourceNode . start ( 0 , sound . playTime ) ;
647652 } else {
648653 if ( sound . playTimeOffset > 0 ) {
649- if ( sound . playTimeOffset > sound . duration ) {
654+ // round duration up as numbers are not integers
655+ // so sometimes it is a tiny bit above
656+ if ( sound . playTimeOffset > Math . ceil ( sound . duration ) ) {
650657 console . warn ( 'playTimeOffset > sound duration' ) ;
651658 }
652659 // if an offset is defined start playing at that position
@@ -675,7 +682,9 @@ export class PlayerCore {
675682 } else {
676683 // if an offset is defined start playing at that position
677684 if ( sound . playTimeOffset > 0 ) {
678- if ( sound . playTimeOffset > sound . duration ) {
685+ // round duration up as numbers are not integers
686+ // so sometimes it is a tiny bit above
687+ if ( sound . playTimeOffset > Math . ceil ( sound . duration ) ) {
679688 console . warn ( 'playTimeOffset > duration' ) ;
680689 }
681690 sound . audioElement . currentTime = sound . playTimeOffset ;
@@ -1237,4 +1246,10 @@ export class PlayerCore {
12371246
12381247 }
12391248
1249+ public getCurrentSound ( ) : ISound {
1250+
1251+ return this . _getSoundFromQueue ( { whichSound : PlayerCore . CURRENT_SOUND } ) ;
1252+
1253+ }
1254+
12401255}
0 commit comments