platypush/platypush/backend/http/static/js/plugins/media/index.js

68 lines
1.5 KiB
JavaScript
Raw Normal View History

// Will be filled by dynamically loading handler scripts
var mediaHandlers = {};
Vue.component('media', {
template: '#tmpl-media',
props: ['config','player'],
data: function() {
return {
bus: new Vue({}),
results: [],
currentItem: {},
2019-06-16 21:45:21 +02:00
selectedDevice: undefined,
loading: {
results: false,
2019-06-16 21:45:21 +02:00
media: false,
},
};
},
computed: {
types: function() {
return mediaHandlers;
},
},
methods: {
refresh: async function() {
},
onResultsLoading: function() {
this.loading.results = true;
},
onResultsReady: function(results) {
this.loading.results = false;
for (var i=0; i < results.length; i++) {
2019-06-16 21:45:21 +02:00
results[i].handler = mediaHandlers[results[i].type];
}
this.results = results;
},
2019-06-16 21:45:21 +02:00
play: async function(item) {
},
info: function(item) {
// TODO
console.log(item);
},
selectDevice: function(device) {
this.selectedDevice = device;
},
},
created: function() {
this.refresh();
2019-06-16 21:45:21 +02:00
this.bus.$on('play', this.play);
this.bus.$on('info', this.info);
this.bus.$on('selected-device', this.selectDevice);
this.bus.$on('results-loading', this.onResultsLoading);
this.bus.$on('results-ready', this.onResultsReady);
},
});