Adding metadata when playing full asset, fixes #340; Shuffle support for playing lists, addresses #307

This commit is contained in:
James Barnsley
2018-11-06 09:06:36 +13:00
parent aea1539a1e
commit aa32904b9a
8 changed files with 49 additions and 17 deletions

View File

@ -21420,7 +21420,8 @@ var AlbumGrid = function (_React$Component) {
e: e,
context: 'album',
uris: [item.uri],
items: [item]
items: [item],
tracklist_uri: item.uri
};
this.props.uiActions.showContextMenu(data);
}
@ -21538,7 +21539,8 @@ var PlaylistGrid = function (_React$Component) {
e: e,
context: 'playlist',
uris: [item.uri],
items: [item]
items: [item],
tracklist_uri: item.uri
};
this.props.uiActions.showContextMenu(data);
}
@ -58471,6 +58473,7 @@ var MopidyMiddleware = function () {
var hashed_hostname = (0, _md2.default)(window.location.hostname);
_reactGa2.default.event({ category: 'Mopidy', action: 'Connected', label: hashed_hostname });
}
store.dispatch(uiActions.createNotification({ content: 'Mopidy connected' }));
next(action);
break;
@ -58480,6 +58483,10 @@ var MopidyMiddleware = function () {
store.dispatch({ type: 'MOPIDY_DISCONNECTED' });
break;
case 'MOPIDY_DISCONNECTED':
store.dispatch(uiActions.createNotification({ type: 'bad', content: 'Mopidy disconnected' }));
break;
case 'MOPIDY_DEBUG':
request(socket, store, action.call, action.value).then(function (response) {
store.dispatch({ type: 'DEBUG', response: response });
@ -58904,10 +58911,17 @@ var MopidyMiddleware = function () {
store.dispatch(mopidyActions.clearTracklist());
}
var first_uri = action.uris[0];
// Shuffle/random mode
if (store.getState().mopidy.random) {
var first_uri_index = Math.floor(Math.random() * action.uris.length);
} else {
var first_uri_index = 0;
}
var first_uri = action.uris[first_uri_index];
// add our first track
request(socket, store, 'tracklist.add', { uri: first_uri, at_position: 0 }).then(function (response) {
// play it (only if we got a successful lookup)
if (response.length > 0) {
store.dispatch(mopidyActions.changeTrack(response[0].tlid));
@ -58921,11 +58935,13 @@ var MopidyMiddleware = function () {
store.dispatch(coreActions.handleException("Mopidy: Failed to add some tracks", response));
}
// add the rest of our uris (if any)
action.uris.shift();
// Remove our first_uri as we've already added it
action.uris.splice(first_uri_index, 1);
// And add the rest of our uris (if any)
if (action.uris.length > 0) {
// wait 100ms so the server can trigger track_changed etc
// Wait a moment so the server can trigger track_changed etc
// this means our UI feels snappier as the first track shows up quickly
setTimeout(function () {
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1541361367";
var build = "1541447978";
var version = "3.29.2";
// Construct the script tag

View File

@ -20,7 +20,8 @@ class AlbumGrid extends React.Component{
e: e,
context: 'album',
uris: [item.uri],
items: [item]
items: [item],
tracklist_uri: item.uri
}
this.props.uiActions.showContextMenu(data)
}

View File

@ -20,7 +20,8 @@ class PlaylistGrid extends React.Component{
e: e,
context: 'playlist',
uris: [item.uri],
items: [item]
items: [item],
tracklist_uri: item.uri
}
this.props.uiActions.showContextMenu(data)
}

View File

@ -228,6 +228,7 @@ const MopidyMiddleware = (function(){
var hashed_hostname = md5(window.location.hostname);
ReactGA.event({ category: 'Mopidy', action: 'Connected', label: hashed_hostname });
}
store.dispatch(uiActions.createNotification({content: 'Mopidy connected'}));
next(action);
break;
@ -237,6 +238,10 @@ const MopidyMiddleware = (function(){
store.dispatch({ type: 'MOPIDY_DISCONNECTED' })
break;
case 'MOPIDY_DISCONNECTED':
store.dispatch(uiActions.createNotification({type: 'bad', content: 'Mopidy disconnected'}));
break;
case 'MOPIDY_DEBUG':
request(socket, store, action.call, action.value )
.then(response => {
@ -758,12 +763,19 @@ const MopidyMiddleware = (function(){
store.dispatch(mopidyActions.clearTracklist());
}
var first_uri = action.uris[0];
// Shuffle/random mode
if (store.getState().mopidy.random){
var first_uri_index = Math.floor(Math.random() * action.uris.length);
} else {
var first_uri_index = 0;
}
var first_uri = action.uris[first_uri_index];
// add our first track
request(socket, store, 'tracklist.add', { uri: first_uri, at_position: 0 })
.then(
response => {
// play it (only if we got a successful lookup)
if (response.length > 0){
store.dispatch(mopidyActions.changeTrack(response[0].tlid));
@ -780,11 +792,13 @@ const MopidyMiddleware = (function(){
));
}
// add the rest of our uris (if any)
action.uris.shift();
// Remove our first_uri as we've already added it
action.uris.splice(first_uri_index, 1);
// And add the rest of our uris (if any)
if (action.uris.length > 0){
// wait 100ms so the server can trigger track_changed etc
// Wait a moment so the server can trigger track_changed etc
// this means our UI feels snappier as the first track shows up quickly
setTimeout(
function(){