11/* eslint-disable @typescript-eslint/no-use-before-define */
2-
3- 'use strict' ;
2+ 'use strict'
43
54// player build
6- import { PlayerCore , ISoundAttributes , ICoreOptions } from '../../../../dist/index.js' ;
5+ import { PlayerCore , ISoundAttributes , ICoreOptions } from '../../../../dist/index.js'
76
87// library
9- import { PlayerUI } from './library/player/ui.js' ;
8+ import { PlayerUI } from './library/player/ui.js'
109
1110// set some options of the player
1211// there are two different sound modes:
@@ -20,16 +19,16 @@ import { PlayerUI } from './library/player/ui.js';
2019const options : ICoreOptions = {
2120 soundsBaseUrl : 'https://mp3l.jamendo.com/?trackid=' ,
2221 playingProgressIntervalTime : 500 ,
23- loadPlayerMode : PlayerCore . PLAYER_MODE_AUDIO
24- } ;
22+ loadPlayerMode : PlayerCore . PLAYER_MODE_AUDIO ,
23+ }
2524
2625// create an instance of the player
27- const player = new PlayerCore ( options ) ;
26+ const player = new PlayerCore ( options )
2827
2928// create an instance of a basic UI we created for this example
3029// as the player does not come with an UI you need to create
3130// your own
32- const playerUI = new PlayerUI ( player ) ;
31+ const playerUI = new PlayerUI ( player )
3332
3433// create a first sound
3534// all you need is to define a source and give each source an ID
@@ -38,92 +37,92 @@ const firstSoundAttributes: ISoundAttributes = {
3837 source : [ { url : '1314412&format=mp31' , codec : 'mp3' } , { url : '1314412&format=ogg1' , codec : 'ogg' , isPreferred : true } ] ,
3938 id : 1314412 ,
4039 onLoading : ( loadingProgress , maximumValue , currentValue ) => {
41- console . log ( 'loading: ' , loadingProgress , maximumValue , currentValue ) ;
42- playerUI . changeLoadingProgress ( loadingProgress ) ;
40+ console . log ( 'loading: ' , loadingProgress , maximumValue , currentValue )
41+ playerUI . changeLoadingProgress ( loadingProgress )
4342 } ,
4443 onPlaying : ( playingProgress , maximumValue , currentValue ) => {
45- console . log ( 'playing: ' , playingProgress , maximumValue , currentValue ) ;
46- playerUI . changePlayingProgress ( playingProgress ) ;
47- console . log ( firstSound ) ;
48- console . log ( 'firstSound.duration: ' , firstSound . duration ) ;
44+ console . log ( 'playing: ' , playingProgress , maximumValue , currentValue )
45+ playerUI . changePlayingProgress ( playingProgress )
46+ console . log ( firstSound )
47+ console . log ( 'firstSound.duration: ' , firstSound . duration )
4948 } ,
5049 onStarted : ( playTimeOffset ) => {
51- console . log ( 'started' , playTimeOffset ) ;
50+ console . log ( 'started' , playTimeOffset )
5251 } ,
5352 onPaused : ( playTimeOffset ) => {
54- console . log ( 'paused' , playTimeOffset ) ;
53+ console . log ( 'paused' , playTimeOffset )
5554 } ,
5655 onStopped : ( playTimeOffset ) => {
57- console . log ( 'stopped' , playTimeOffset ) ;
56+ console . log ( 'stopped' , playTimeOffset )
5857 } ,
5958 onResumed : ( playTimeOffset ) => {
60- console . log ( 'resumed' , playTimeOffset ) ;
59+ console . log ( 'resumed' , playTimeOffset )
6160 } ,
6261 onEnded : ( willPlayNext ) => {
63- console . log ( 'ended' , willPlayNext ) ;
62+ console . log ( 'ended' , willPlayNext )
6463 if ( ! willPlayNext ) {
65- playerUI . resetUI ( ) ;
64+ playerUI . resetUI ( )
6665 }
6766 }
68- } ;
67+ }
6968
7069// add the first to the songs (sounds) queue
71- const firstSound = player . addSoundToQueue ( { soundAttributes : firstSoundAttributes } ) ;
70+ const firstSound = player . addSoundToQueue ( { soundAttributes : firstSoundAttributes } )
7271
73- console . log ( firstSound ) ;
72+ console . log ( firstSound )
7473
7574// create a second sound
7675const secondSoundAttributes : ISoundAttributes = {
7776 source : [ { url : '1214935&format=mp31' , codec : 'mp3' } , { url : '1214935&format=ogg1' , codec : 'ogg' , isPreferred : true } ] ,
7877 id : 1214935 ,
7978 onLoading : ( loadingProgress , maximumValue , currentValue ) => {
80- console . log ( 'loading: ' , loadingProgress , maximumValue , currentValue ) ;
81- playerUI . changeLoadingProgress ( loadingProgress ) ;
79+ console . log ( 'loading: ' , loadingProgress , maximumValue , currentValue )
80+ playerUI . changeLoadingProgress ( loadingProgress )
8281 } ,
8382 onPlaying : ( playingProgress , maximumValue , currentValue ) => {
84- console . log ( 'playing: ' , playingProgress , maximumValue , currentValue ) ;
85- playerUI . changePlayingProgress ( playingProgress ) ;
83+ console . log ( 'playing: ' , playingProgress , maximumValue , currentValue )
84+ playerUI . changePlayingProgress ( playingProgress )
8685 } ,
8786 onStarted : ( playTimeOffset ) => {
88- console . log ( 'started' , playTimeOffset ) ;
87+ console . log ( 'started' , playTimeOffset )
8988 } ,
9089 onPaused : ( playTimeOffset ) => {
91- console . log ( 'paused' , playTimeOffset ) ;
90+ console . log ( 'paused' , playTimeOffset )
9291 } ,
9392 onStopped : ( playTimeOffset ) => {
94- console . log ( 'stopped' , playTimeOffset ) ;
93+ console . log ( 'stopped' , playTimeOffset )
9594 } ,
9695 onResumed : ( playTimeOffset ) => {
97- console . log ( 'resumed' , playTimeOffset ) ;
96+ console . log ( 'resumed' , playTimeOffset )
9897 } ,
9998 onEnded : ( willPlayNext ) => {
100- console . log ( 'ended' , willPlayNext ) ;
99+ console . log ( 'ended' , willPlayNext )
101100 if ( ! willPlayNext ) {
102- playerUI . resetUI ( ) ;
101+ playerUI . resetUI ( )
103102 }
104103 }
105- } ;
104+ }
106105
107106// add the second song (sound) to the queue
108- const secondSound = player . addSoundToQueue ( { soundAttributes : secondSoundAttributes } ) ;
107+ const secondSound = player . addSoundToQueue ( { soundAttributes : secondSoundAttributes } )
109108
110- console . log ( secondSound ) ;
109+ console . log ( secondSound )
111110
112111// turn the automute feature on/off: if page becomes invisible auto mute, unmute when page becomes visible again
113- player . setVisibilityAutoMute ( true ) ;
112+ player . setVisibilityAutoMute ( true )
114113
115114// halt the audio hardware access temporarily to reduce CPU and battery usage
116115/*player.getAudioContext().then((audioContext) => {
117- audioContext.suspend();
118- console.log(audioContext.state);
119- }); */
116+ audioContext.suspend()
117+ console.log(audioContext.state)
118+ })*/
120119
121- //let volume = 90;
120+ //let volume = 90
122121
123- //player.setVolume(volume);
122+ //player.setVolume(volume)
124123
125124// play first song in the queue
126- //player.play();
125+ //player.play()
127126
128127// play next song
129- //player.play(player.PLAY_SOUND_NEXT);
128+ //player.play(player.PLAY_SOUND_NEXT)
0 commit comments