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: {},
|
|
|
|
loading: {
|
|
|
|
results: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
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++) {
|
|
|
|
results[i].handler = {};
|
|
|
|
|
|
|
|
for (const hndl of Object.values(mediaHandlers)) {
|
|
|
|
if (hndl.matchesUrl(results[i].url)) {
|
|
|
|
results[i].handler = hndl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-14 00:54:20 +02:00
|
|
|
this.results = results;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created: function() {
|
|
|
|
this.refresh();
|
|
|
|
|
|
|
|
this.bus.$on('results-loading', this.onResultsLoading);
|
|
|
|
this.bus.$on('results-ready', this.onResultsReady);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|