2019-06-15 00:51:48 +02:00
|
|
|
// Will be filled by dynamically loading handler scripts
|
|
|
|
var mediaHandlers = {};
|
|
|
|
|
2019-06-14 00:54:20 +02:00
|
|
|
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,
|
2019-06-14 00:54:20 +02:00
|
|
|
loading: {
|
|
|
|
results: false,
|
2019-06-16 21:45:21 +02:00
|
|
|
media: false,
|
2019-06-14 00:54:20 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
types: function() {
|
2019-06-15 00:51:48 +02:00
|
|
|
return mediaHandlers;
|
2019-06-14 00:54:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
refresh: async function() {
|
|
|
|
},
|
|
|
|
|
|
|
|
onResultsLoading: function() {
|
|
|
|
this.loading.results = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onResultsReady: function(results) {
|
|
|
|
this.loading.results = false;
|
2019-06-15 00:51:48 +02:00
|
|
|
|
|
|
|
for (var i=0; i < results.length; i++) {
|
2019-06-16 21:45:21 +02:00
|
|
|
results[i].handler = mediaHandlers[results[i].type];
|
2019-06-15 00:51:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-14 00:54:20 +02:00
|
|
|
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;
|
|
|
|
},
|
2019-06-14 00:54:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
2019-06-14 00:54:20 +02:00
|
|
|
this.bus.$on('results-loading', this.onResultsLoading);
|
|
|
|
this.bus.$on('results-ready', this.onResultsReady);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|