Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add mediasession support #8309

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
mister-ben committed Jun 3, 2023
commit d892c1660e364f55c4209f7dbfe00024b8386b5a
19 changes: 10 additions & 9 deletions test/unit/mediasession.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,44 +189,45 @@ QUnit.test('mediasession artwork', function(assert) {
artwork: [{
src: 'https://example.com/getmedia'
}]
}
};
};

this.player.playlist = () => {
return [{
artwork: [{
src: 'https://example.com/playlist'
}]
}]
}];
};
this.player.playlist.currentItem = () => 0;


this.player.one('updatemediasession', (e, metadata) => {
assert.equal(metadata.artwork[0].src, 'https://example.com/getmedia', 'set with loadMedia data');
});
this.player.trigger('playing');
this.clock.tick(100);

this.player.getMedia = () => { return {}; };
this.player.getMedia = () => {
return {};
};
this.player.usingPlugin = () => true;

this.player.one('updatemediasession', (e, metadata) => {
assert.equal(metadata.artwork[0].src, 'https://example.com/playlist', 'set with playlist data');
});
this.player.trigger('playing');
this.clock.tick(100);

this.player.usingPlugin = () => false;

this.player.one('updatemediasession', (e, metadata) => {
assert.equal(metadata.artwork[0].src, 'https://example.com/poster', 'set with poster data');
});
this.player.trigger('playing');
this.player.trigger('playing');
this.clock.tick(100);

this.player.poster(null);

this.player.one('updatemediasession', (e, metadata) => {
assert.equal(metadata.artwork, undefined, 'omitted with no data');
});
Expand Down Expand Up @@ -273,7 +274,7 @@ QUnit.test('allows for action handlers that are not settable', function(assert)
this.player = TestHelpers.makePlayer({
mediaSession: true
});

sinon.stub(this.player.log, 'debug');

this.player.trigger('pluginsetup:playlist');
Expand Down