44 */
55
66import throttle = require( 'lodash.throttle' ) ;
7- import { AudioPlayerWrapper } from './AudioPlayerWrapper' ;
87import { commandFactory } from './CommandFactory' ;
98import { componentFactory } from './ComponentFactory' ;
109import { ActionableComponent } from './components/ActionableComponent' ;
@@ -22,7 +21,7 @@ import { PointerType } from './enums/PointerType';
2221import { IExtensionManager } from './extensions/IExtensionManager' ;
2322import { ILogger } from './logging/ILogger' ;
2423import { LoggerFactory } from './logging/LoggerFactory' ;
25- import { AudioPlayerFactory } from './media/audio/AudioPlayer ' ;
24+ import { AudioPlayerFactory , IAudioPlayerFactory } from './media/audio/AudioPlayerFactory ' ;
2625import { createAplVersionUtils } from './utils/AplVersionUtils' ;
2726import { browserIsEdge } from './utils/BrowserUtils' ;
2827import { ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT , ARROW_UP , ENTER_KEY , HttpStatusCodes } from './utils/Constant' ;
@@ -210,7 +209,7 @@ export interface IAPLOptions {
210209 /** Device mode. If no provided "HUB" is used. */
211210 mode ?: DeviceMode ;
212211
213- /** Optional externalized audio player */
212+ /** Optional externalized audio player factory */
214213 audioPlayerFactory ?: AudioPlayerFactory ;
215214
216215 /** Callback for executed SendEvent commands */
@@ -310,6 +309,12 @@ export default abstract class APLRenderer<Options = any> {
310309 */
311310 protected abstract getDocumentAplVersion ( ) : string ;
312311
312+ /**
313+ * @internal
314+ * @ignore
315+ */
316+ protected abstract getAudioPlayerFactory ( ) : IAudioPlayerFactory ;
317+
313318 /** A reference to the APL root context */
314319 public context : APL . Context ;
315320
@@ -329,6 +334,7 @@ export default abstract class APLRenderer<Options = any> {
329334 this . handleConfigurationChange ( configurationChangeOptions ) ;
330335 } , 200 ) ;
331336
337+ /** Display state change handler */
332338 protected handleUpdateDisplayState : ( displayState : DisplayState ) => void ;
333339
334340 /**
@@ -391,14 +397,16 @@ export default abstract class APLRenderer<Options = any> {
391397 */
392398 private dropFrameCount : number = 0 ;
393399
400+ /**
401+ * @internal
402+ * @ignore
403+ */
394404 private isEdge : boolean = browserIsEdge ( window . navigator . userAgent ) ;
395405
396406 public get options ( ) : Options {
397407 return this . mOptions as any as Options ;
398408 }
399409
400- public audioPlayer : AudioPlayerWrapper ;
401-
402410 /**
403411 * THis constructor is private
404412 * @param mOptions options passed in through `create`
@@ -500,8 +508,6 @@ export default abstract class APLRenderer<Options = any> {
500508 this . onResizingIgnored = mOptions . onResizingIgnored ;
501509 }
502510
503- this . audioPlayer = new AudioPlayerWrapper ( mOptions . audioPlayerFactory ) ;
504-
505511 this . maxTimeDeltaBetweenFrames = ( 1000 * this . TOLERANCE / this . MAXFPS ) ;
506512 }
507513
@@ -775,7 +781,6 @@ export default abstract class APLRenderer<Options = any> {
775781 }
776782 ( this . context as any ) = undefined ;
777783 }
778- this . destroyAudioPlayer ( ) ;
779784 this . removeRenderingComponents ( ) ;
780785 if ( this . view ) {
781786 for ( const eventName in this . viewEventListeners ) {
@@ -974,6 +979,10 @@ export default abstract class APLRenderer<Options = any> {
974979 * @ignore
975980 */
976981 private coreFrameUpdate ( ) : void {
982+ if ( this . getAudioPlayerFactory ( ) ) {
983+ this . getAudioPlayerFactory ( ) . tick ( ) ;
984+ }
985+
977986 this . updateTime ( ) ;
978987
979988 this . context . clearPending ( ) ;
@@ -1303,11 +1312,4 @@ export default abstract class APLRenderer<Options = any> {
13031312 }
13041313 }
13051314 }
1306-
1307- private destroyAudioPlayer ( ) : void {
1308- if ( this . audioPlayer ) {
1309- this . audioPlayer . destroy ( ) ;
1310- this . audioPlayer = null ;
1311- }
1312- }
13131315}
0 commit comments