Merge branch 'develop'
This commit is contained in:
@ -1 +1 @@
|
||||
3.55.3
|
||||
3.55.4
|
||||
@ -3,7 +3,7 @@ import pathlib
|
||||
|
||||
from mopidy import config, ext
|
||||
|
||||
__version__ = "3.55.3"
|
||||
__version__ = "3.55.4"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -107086,6 +107086,9 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "actionHandler", function (action) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
seekTime = _ref.seekTime;
|
||||
|
||||
var _this$props = _this.props,
|
||||
actions = _this$props.mopidyActions,
|
||||
time_position = _this$props.time_position;
|
||||
@ -107104,6 +107107,11 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
return actions.setTimePosition(time_position + 30000); // 30 seconds
|
||||
}
|
||||
|
||||
case 'seekto':
|
||||
{
|
||||
return actions.setTimePosition(seekTime * 1000);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return actions[action]();
|
||||
@ -107112,6 +107120,7 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "render", function () {
|
||||
var audioRef = _this.state.audioRef;
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||
@ -107123,6 +107132,7 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
style: {
|
||||
display: 'none'
|
||||
},
|
||||
ref: audioRef,
|
||||
"data-qa-node": "audio",
|
||||
"data-qa-file": "MediaSession"
|
||||
})
|
||||
@ -107131,7 +107141,9 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
|
||||
_this.state = {
|
||||
current_track: null,
|
||||
stream_title: null
|
||||
stream_title: null,
|
||||
audioRef: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef() // Allows access from within getDerivedStateFromProps
|
||||
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
@ -107149,11 +107161,8 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
mediaSession.setActionHandler('pause', function () {
|
||||
return _this2.actionHandler('pause');
|
||||
});
|
||||
mediaSession.setActionHandler('seekbackward', function () {
|
||||
return _this2.actionHandler('seekbackward');
|
||||
});
|
||||
mediaSession.setActionHandler('seekforward', function () {
|
||||
return _this2.actionHandler('seekforward');
|
||||
mediaSession.setActionHandler('seekto', function (position) {
|
||||
return _this2.actionHandler('seekto', position);
|
||||
});
|
||||
mediaSession.setActionHandler('previoustrack', function () {
|
||||
return _this2.actionHandler('previous');
|
||||
@ -107164,13 +107173,15 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(_ref, state) {
|
||||
var current_track = _ref.current_track,
|
||||
stream_title = _ref.stream_title,
|
||||
play_state = _ref.play_state;
|
||||
value: function getDerivedStateFromProps(_ref2, state) {
|
||||
var current_track = _ref2.current_track,
|
||||
_ref2$stream_title = _ref2.stream_title,
|
||||
stream_title = _ref2$stream_title === void 0 ? null : _ref2$stream_title,
|
||||
play_state = _ref2.play_state,
|
||||
time_position = _ref2.time_position;
|
||||
|
||||
if (current_track) {
|
||||
var title = current_track.title,
|
||||
var name = current_track.name,
|
||||
_current_track$album = current_track.album,
|
||||
album = _current_track$album === void 0 ? {} : _current_track$album,
|
||||
_current_track$artist = current_track.artists,
|
||||
@ -107179,17 +107190,29 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
images = _current_track$images === void 0 ? {} : _current_track$images;
|
||||
|
||||
if (current_track.duration) {
|
||||
navigator.mediaSession.setPositionState({
|
||||
duration: current_track.duration,
|
||||
playbackRate: 1,
|
||||
position: 0
|
||||
});
|
||||
// Only supported on Android as of Chrome 81 and later.
|
||||
if ('setPositionState' in navigator.mediaSession) {
|
||||
var newPositionState = {
|
||||
duration: Math.round(current_track.duration / 1000),
|
||||
position: Math.round(time_position / 1000),
|
||||
playbackRate: 1
|
||||
};
|
||||
|
||||
try {
|
||||
navigator.mediaSession.setPositionState(newPositionState);
|
||||
} catch (error) {
|
||||
console.error('Failed to set MediaSession position', {
|
||||
newPositionState: newPositionState,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
navigator.mediaSession.metadata = new window.MediaMetadata({
|
||||
title: stream_title || title || '-',
|
||||
artist: artists.length ? artists[0].name : '-',
|
||||
album: album.name || '-',
|
||||
title: stream_title || name || 'Unknown track',
|
||||
artist: artists.length ? artists[0].name : 'Unknown artist',
|
||||
album: album.name || 'Unknown album',
|
||||
artwork: [].concat(_toConsumableArray(images.small ? [{
|
||||
src: images.small,
|
||||
sizes: '96x96',
|
||||
@ -107208,6 +107231,15 @@ var MediaSession = /*#__PURE__*/function (_React$Component) {
|
||||
|
||||
if (navigator.mediaSession.playbackState !== play_state) {
|
||||
navigator.mediaSession.playbackState = play_state;
|
||||
var current = state.audioRef.current;
|
||||
|
||||
if (current) {
|
||||
if (play_state === 'paused') {
|
||||
current.pause();
|
||||
} else {
|
||||
current.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
mopidy_iris/static/app.min.js
vendored
2
mopidy_iris/static/app.min.js
vendored
File diff suppressed because one or more lines are too long
@ -106,8 +106,8 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1607766411";
|
||||
var version = "3.55.3";
|
||||
var build = "1607846624";
|
||||
var version = "3.55.4";
|
||||
|
||||
// Construct the script tag
|
||||
var js = document.createElement("script");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"manifest_version": "3.55.3",
|
||||
"manifest_version": "3.55.4",
|
||||
"short_name": "Iris",
|
||||
"name": "Iris",
|
||||
"icons": [
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mopidy-iris",
|
||||
"version": "3.55.3",
|
||||
"version": "3.55.4",
|
||||
"description": "Mopidy HTTP interface",
|
||||
"repository": "https://github.com/jaedb/iris",
|
||||
"author": "James Barnsley <james@barnsley.nz>",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = Mopidy-Iris
|
||||
version = 3.55.3
|
||||
version = 3.55.4
|
||||
url = https://github.com/jaedb/iris
|
||||
author = James Barnsley
|
||||
author_email = james@barnsley.nz
|
||||
|
||||
@ -9,6 +9,7 @@ class MediaSession extends React.Component {
|
||||
this.state = {
|
||||
current_track: null,
|
||||
stream_title: null,
|
||||
audioRef: React.createRef(), // Allows access from within getDerivedStateFromProps
|
||||
};
|
||||
}
|
||||
|
||||
@ -19,33 +20,48 @@ class MediaSession extends React.Component {
|
||||
|
||||
mediaSession.setActionHandler('play', () => this.actionHandler('play'));
|
||||
mediaSession.setActionHandler('pause', () => this.actionHandler('pause'));
|
||||
mediaSession.setActionHandler('seekbackward', () => this.actionHandler('seekbackward'));
|
||||
mediaSession.setActionHandler('seekforward', () => this.actionHandler('seekforward'));
|
||||
mediaSession.setActionHandler('seekto', (position) => this.actionHandler('seekto', position));
|
||||
mediaSession.setActionHandler('previoustrack', () => this.actionHandler('previous'));
|
||||
mediaSession.setActionHandler('nexttrack', () => this.actionHandler('next'));
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps({ current_track, stream_title, play_state }, state) {
|
||||
static getDerivedStateFromProps(
|
||||
{
|
||||
current_track,
|
||||
stream_title = null,
|
||||
play_state,
|
||||
time_position,
|
||||
},
|
||||
state,
|
||||
) {
|
||||
if (current_track) {
|
||||
const {
|
||||
title,
|
||||
name,
|
||||
album = {},
|
||||
artists = [],
|
||||
images = {},
|
||||
} = current_track;
|
||||
|
||||
if (current_track.duration) {
|
||||
navigator.mediaSession.setPositionState({
|
||||
duration: current_track.duration,
|
||||
playbackRate: 1,
|
||||
position: 0,
|
||||
});
|
||||
// Only supported on Android as of Chrome 81 and later.
|
||||
if ('setPositionState' in navigator.mediaSession) {
|
||||
const newPositionState = {
|
||||
duration: Math.round(current_track.duration / 1000),
|
||||
position: Math.round(time_position / 1000),
|
||||
playbackRate: 1,
|
||||
};
|
||||
try {
|
||||
navigator.mediaSession.setPositionState(newPositionState);
|
||||
} catch (error) {
|
||||
console.error('Failed to set MediaSession position', { newPositionState, error });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
navigator.mediaSession.metadata = new window.MediaMetadata({
|
||||
title: stream_title || title || '-',
|
||||
artist: artists.length ? artists[0].name : '-',
|
||||
album: album.name || '-',
|
||||
title: stream_title || name || 'Unknown track',
|
||||
artist: artists.length ? artists[0].name : 'Unknown artist',
|
||||
album: album.name || 'Unknown album',
|
||||
artwork: [
|
||||
...(images.small ? [{
|
||||
src: images.small,
|
||||
@ -68,6 +84,19 @@ class MediaSession extends React.Component {
|
||||
|
||||
if (navigator.mediaSession.playbackState !== play_state) {
|
||||
navigator.mediaSession.playbackState = play_state;
|
||||
const {
|
||||
audioRef: {
|
||||
current,
|
||||
},
|
||||
} = state;
|
||||
|
||||
if (current) {
|
||||
if (play_state === 'paused') {
|
||||
current.pause();
|
||||
} else {
|
||||
current.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@ -77,7 +106,7 @@ class MediaSession extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
actionHandler = (action) => {
|
||||
actionHandler = (action, { seekTime } = {}) => {
|
||||
const {
|
||||
mopidyActions: actions,
|
||||
time_position,
|
||||
@ -92,6 +121,9 @@ class MediaSession extends React.Component {
|
||||
case 'seekforward': {
|
||||
return actions.setTimePosition(time_position + 30000); // 30 seconds
|
||||
}
|
||||
case 'seekto': {
|
||||
return actions.setTimePosition(seekTime * 1000);
|
||||
}
|
||||
default: {
|
||||
return actions[action]();
|
||||
}
|
||||
@ -99,6 +131,8 @@ class MediaSession extends React.Component {
|
||||
}
|
||||
|
||||
render = () => {
|
||||
const { audioRef } = this.state;
|
||||
|
||||
return (
|
||||
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||
<audio
|
||||
@ -107,6 +141,7 @@ class MediaSession extends React.Component {
|
||||
autoPlay
|
||||
loop
|
||||
style={{ display: 'none' }}
|
||||
ref={audioRef}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user