Koa*_*la7 1 javascript ember.js ember-cli ember-components
我有一个音乐组件播放从我的网站音乐页面内的SoundCloud API检索到的收藏歌曲.
{{soundcloud-player favorite=currentFavorite sound=currentFavoriteObject position=currentFavoritePosition isPlaying=isPlaying isBuffering=isBuffering}}
Run Code Online (Sandbox Code Playgroud)
问题是,一旦我播放了一首歌,我改变了网站的页面(路线),歌曲继续播放,解决它我需要随时设置 isPlaying false我改变route页面的音乐.
我看到有不同的方法来实现它,但我无法弄清楚我的情况
米尝试
来自不同的控制器
needs:'player',
desactivateIsplaying: function(){
var controller = this.get('controllers.player');
controller.set('isPlaying', false);
}
Run Code Online (Sandbox Code Playgroud)
或者来自不同的路线
desactivateIsPlaying: function(){
var controller = this.controllerFor('player');
controller.set('isPlaying', false);
}
Run Code Online (Sandbox Code Playgroud)
在我无法设置的两个功能中的任何一个isPlaying false,我也看到提到willTransition路线动作,我该如何使用它?有没有更好的方法呢?如果有必要,我可以制作一个旋转的余烬,以更好地再现场景
willTransition在您的路线上使用是一个不错的选择.
音乐/ route.js
import Ember from 'ember';
const { Route } = Ember;
export default Route.extend({
actions: {
willTransition() {
this.controller.set('isPlaying', false);
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2514 次 |
| 最近记录: |