ngx-soundmanager2
Version:
SoundManager2 Music Player for Angular2+
82 lines • 2.61 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
import { Directive, HostListener, ElementRef } from '@angular/core';
import { MusicPlayerService } from './music-player.service';
export class RepeatMusicDirective {
/**
* @param {?} _musicPlayerService
* @param {?} _element
*/
constructor(_musicPlayerService, _element) {
this._musicPlayerService = _musicPlayerService;
this._element = _element;
}
/**
* @return {?}
*/
ngOnInit() {
this.repeat = this._musicPlayerService.getRepeatStatus();
this.highlight();
// Subscribe for repeat changes to update bindings
this._musicPlayerRepeatSubscription = this._musicPlayerService.musicPlayerRepeatEventEmitter
.subscribe((event) => {
this.repeat = event.data;
this.highlight();
});
}
/**
* @return {?}
*/
ngOnDestroy() {
this._musicPlayerRepeatSubscription.unsubscribe();
}
/**
* Element click event handler
* @return {?}
*/
onClick() {
this._musicPlayerService.repeatToggle();
}
/**
* Change background color of element based on repeat state
* @return {?}
*/
highlight() {
this._element.nativeElement.style.backgroundColor = this.repeat ? 'green' : 'red';
}
}
RepeatMusicDirective.decorators = [
{ type: Directive, args: [{
selector: '[repeatMusic]'
},] }
];
/** @nocollapse */
RepeatMusicDirective.ctorParameters = () => [
{ type: MusicPlayerService, },
{ type: ElementRef, },
];
RepeatMusicDirective.propDecorators = {
"onClick": [{ type: HostListener, args: ['click', ['$event'],] },],
};
function RepeatMusicDirective_tsickle_Closure_declarations() {
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
RepeatMusicDirective.decorators;
/**
* @nocollapse
* @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>}
*/
RepeatMusicDirective.ctorParameters;
/** @type {!Object<string,!Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
RepeatMusicDirective.propDecorators;
/** @type {?} */
RepeatMusicDirective.prototype.repeat;
/** @type {?} */
RepeatMusicDirective.prototype._musicPlayerRepeatSubscription;
/** @type {?} */
RepeatMusicDirective.prototype._musicPlayerService;
/** @type {?} */
RepeatMusicDirective.prototype._element;
}
//# sourceMappingURL=repeat-music.directive.js.map