aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Dapena Paz <jdapena@igalia.com>2022-05-31 16:21:54 +0200
committerJose Dapena Paz <jdapena@igalia.com>2022-06-01 11:04:37 +0200
commit266985a5eddc7df30126e79105e22dfb1dae140c (patch)
tree3fe2dd59b9dbe642484f86aec55c8b5b567d4c97
parent9fcfee6f23fb9aa2f59e65a8b3f5bdb9aa64ec23 (diff)
Adapt to new application framework
Drop usage of agl-js-api, and just provide a mock for mediaplayer calls. Bug-AGL: SPEC-4248 Signed-off-by: Jose Dapena Paz <jdapena@igalia.com> Change-Id: I8461713c56f2a81e3e1eda441e10da45f96c8087
-rw-r--r--src/index.js3
-rw-r--r--src/js/agl_stubs_mediaplayer.js49
-rw-r--r--src/js/app.js2
-rw-r--r--src/js/player.js2
-rw-r--r--src/js/playlist.js2
-rw-r--r--src/js/templates.js4
6 files changed, 53 insertions, 9 deletions
diff --git a/src/index.js b/src/index.js
index f1644ae..9ad7774 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,13 +18,10 @@ import * as app from './js/app';
import * as player from './js/player';
import * as playlist from './js/playlist';
-import { api } from 'agl-js-api';
-
/* CSS */
import './styles/app.scss';
window.player = player;
window.playlist = playlist;
-api.init();
app.init();
diff --git a/src/js/agl_stubs_mediaplayer.js b/src/js/agl_stubs_mediaplayer.js
new file mode 100644
index 0000000..ef26f23
--- /dev/null
+++ b/src/js/agl_stubs_mediaplayer.js
@@ -0,0 +1,49 @@
+export function on_metadata_changes() {
+}
+
+export function on_playlist_changes() {
+}
+
+export function loop() {
+ return new Promise((resolve, reject) => {
+ resolve();
+ });
+}
+
+export function pickTrack() {
+}
+
+export function play() {
+ return new Promise((resolve, reject) => {
+ resolve();
+ });
+}
+
+export function pause() {
+}
+
+export function previous() {
+}
+
+export function next() {
+}
+
+export function seek() {
+}
+
+function get_test_playlist() {
+ return {
+ playlist: [
+ { index: 1, title: "Title 1", genre: "Genre 1", artist: "Artist 1"},
+ { index: 2, title: "Title 2", genre: "Genre 2", artist: "Artist 2"},
+ { index: 3, title: "Title 3", genre: "Genre 3", artist: "Artist 3"},
+ { index: 4, title: "Title 4", genre: "Genre 4", artist: "Artist 4"},
+ ]
+ };
+}
+
+export function playlist() {
+ return new Promise((resolve, reject) => {
+ resolve(get_test_playlist());
+ });
+}
diff --git a/src/js/app.js b/src/js/app.js
index 2e53754..40be774 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -3,8 +3,6 @@ import * as player from './player';
import * as playlist from './playlist';
import Mustache from 'mustache';
-import { mediaplayer } from 'agl-js-api';
-
var template;
var page = {
diff --git a/src/js/player.js b/src/js/player.js
index 3fc34c7..b3e8173 100644
--- a/src/js/player.js
+++ b/src/js/player.js
@@ -1,7 +1,7 @@
import { load as load_template } from './templates';
import Mustache from 'mustache';
-import { mediaplayer } from 'agl-js-api';
+import * as mediaplayer from './agl_stubs_mediaplayer';
var template;
var root;
diff --git a/src/js/playlist.js b/src/js/playlist.js
index 4739efc..0536816 100644
--- a/src/js/playlist.js
+++ b/src/js/playlist.js
@@ -1,7 +1,7 @@
import { load as load_template } from './templates';
import Mustache from 'mustache';
-import { mediaplayer } from 'agl-js-api';
+import * as mediaplayer from './agl_stubs_mediaplayer';
var template;
var root;
diff --git a/src/js/templates.js b/src/js/templates.js
index 2513722..4b71638 100644
--- a/src/js/templates.js
+++ b/src/js/templates.js
@@ -2,12 +2,12 @@ export function load(template) {
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
- xhr.open('GET', '/templates/'+template);
+ xhr.open('GET', './templates/'+template);
xhr.send();
xhr.onload = function() {
- if (xhr.status != 200) {
+ if (xhr.status != 200 && xhr.status != 0) {
console.error('Error loading template', xhr.status, xhr.statusText);
reject(xhr.status);
} else {