我正在尝试构建一个Glimmer组件,该组件可以对服务中的属性更改做出React,请参见下面的内容,我正在尝试使该组件更新get playing以响应audioPlayer url和状态的更改-当在下面的播放操作中按下播放按钮时,这些更改就会发生a a....这不起作用,而且我还没有找到任何文档来支持这种行为。
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ShowAudioEpisodeComponent extends Component {
@service audioPlayer;
get playing() {
return this.audioPlayer.url == this.args.epi.audioUrl && this.audioPlayer.status == "playing";
}
@action
play() {
if (this.playing) {
this.audioPlayer.pause(this.args.epi);
} else {
this.audioPlayer.playEpisode(this.args.epi);
}
}
}
1条答案
按热度按时间o4hqfura1#
audio-player
服务必须将url
和status
声明为@tracked
,或者必须始终使用set
更新它们