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