Added playQueue support. Latest PMP playback now works!

This commit is contained in:
Travis Shivers 2020-06-21 17:14:44 -05:00
parent 3f809b2218
commit 1fdf14afcd
8 changed files with 38 additions and 19 deletions

17
package-lock.json generated
View File

@ -4672,15 +4672,6 @@
}
}
},
"enquirer": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.5.tgz",
"integrity": "sha512-BNT1C08P9XD0vNg3J475yIUG+mVdp9T6towYFHUv897X0KoHBjB1shyrNmhmtHWKP17iSWgo7Gqh7BBuzLZMSA==",
"dev": true,
"requires": {
"ansi-colors": "^3.2.1"
}
},
"entities": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz",
@ -4756,9 +4747,9 @@
"dev": true
},
"eslint": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.3.0.tgz",
"integrity": "sha512-dJMVXwfU5PT1cj2Nv2VPPrKahKTGdX+5Dh0Q3YuKt+Y2UhdL2YbzsVaBMyG9HC0tBismlv/r1+eZqs6SMIV38Q==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.2.0.tgz",
"integrity": "sha512-B3BtEyaDKC5MlfDa2Ha8/D6DsS4fju95zs0hjS3HdGazw+LNayai38A25qMppK37wWGWNYSPOR6oYzlz5MHsRQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
@ -4767,7 +4758,6 @@
"cross-spawn": "^7.0.2",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"enquirer": "^2.3.5",
"eslint-scope": "^5.1.0",
"eslint-utils": "^2.0.0",
"eslint-visitor-keys": "^1.2.0",
@ -4781,6 +4771,7 @@
"ignore": "^4.0.6",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"inquirer": "^7.0.0",
"is-glob": "^4.0.0",
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",

View File

@ -41,7 +41,7 @@
"babel-eslint": "^10.1.0",
"date-fns": "^2.14.0",
"detect-browser": "^5.1.1",
"eslint": "^7.3.0",
"eslint": "^7.2.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-vue": "^6.2.2",
"fast-xml-parser": "^3.17.4",

View File

@ -27,7 +27,7 @@ export default {
'X-Plex-Platform': getters.GET_PLEX_PLATFORM_HEADER,
'X-Plex-Platform-Version': browser.version,
// 'X-Plex-Sync-Version': 2,
// 'X-Plex-Features': 'external-media,indirect-media',
'X-Plex-Features': 'external-media,indirect-media',
'X-Plex-Model': 'hosted',
'X-Plex-Device': getters.GET_PLEX_DEVICE_DEVICE_HEADER,
'X-Plex-Device-Name': getters.GET_PLEX_DEVICE_NAME_HEADER,

View File

@ -68,7 +68,13 @@ export default {
// MediaId Key, Offset, server MachineId,
// Server Ip, Server Port, Server Protocol, Path
await dispatch('plexservers/CREATE_PLAY_QUEUE', {
machineIdentifier,
ratingKey: metadata.ratingKey,
}, { root: true });
// TODO: potentially wait for stuff..
await dispatch('SEND_CLIENT_REQUEST', {
path: '/player/playback/playMedia',
params: {
@ -81,6 +87,7 @@ export default {
protocol: server.chosenConnection.protocol,
path: server.chosenConnection.uri + metadata.key,
token: server.accessToken,
containerKey: `/playQueues/${rootGetters['plexservers/GET_PLAY_QUEUE_ID']}`,
...mediaIndex && { mediaIndex },
},
});
@ -133,8 +140,8 @@ export default {
commit('SET_ACTIVE_MEDIA_METADATA', null);
commit('SET_ACTIVE_SERVER_ID', null);
} else {
// If client has changed what it's playing
// TODO: see what client sends when its stopped and set metadata and stuff to null instead if so
// If client has changed what it's playing
// TODO: see what client sends when its stopped and set metadata and stuff to null instead if so
commit('SET_ACTIVE_MEDIA_METADATA', await dispatch('plexservers/FETCH_PLEX_METADATA', {
machineIdentifier: timeline.machineIdentifier,
ratingKey: timeline.ratingKey,
@ -230,7 +237,7 @@ export default {
const difference = Math.abs(adjustedHostTime - adjustedTime);
const bothPaused = rootGetters['synclounge/GET_HOST_TIMELINE'].playerState === 'paused'
&& playerPollData.playerState === 'paused';
&& playerPollData.playerState === 'paused';
console.log('difference: ', difference);
if (difference > rootGetters['settings/GET_SYNCFLEXIBILITY'] || (bothPaused && difference > 10)) {

View File

@ -73,7 +73,7 @@ export default {
CACHE_METADATA_TITLES: ({ commit }, { machineIdentifier, result }) => {
// This data is used in our router breadcrumbs
if (result.Metadata
&& result.Metadata.length > 0
&& result.Metadata.length > 0
) {
result.Metadata.forEach((item) => {
if (item.ratingKey) {
@ -263,4 +263,18 @@ export default {
return data.MediaContainer.Hub[0].Metadata[0];
},
CREATE_PLAY_QUEUE: async ({ getters, commit }, { machineIdentifier, ratingKey }) => {
const { data } = await getters.GET_PLEX_SERVER_AXIOS(machineIdentifier).post('/playQueues', null, {
params: {
type: 'video',
continuous: 1,
uri: `server://${machineIdentifier}/com.plexapp.plugins.library/library/metadata/${ratingKey}`,
own: 1,
includeExternalMedia: 1,
},
});
commit('SET_PLAY_QUEUE_ID', data.MediaContainer.playQueueID);
},
};

View File

@ -59,4 +59,6 @@ export default {
},
GET_BLOCKED_SERVER_IDS: (state) => state.blockedServerIds,
GET_PLAY_QUEUE_ID: (state) => state.playQueueId,
};

View File

@ -12,4 +12,8 @@ export default {
SET_BLOCKED_SERVER_IDS: (state, blockedIds) => {
state.blockedServerIds = blockedIds;
},
SET_PLAY_QUEUE_ID: (state, id) => {
state.playQueueId = id;
},
};

View File

@ -2,6 +2,7 @@ const state = () => ({
servers: {},
lastServerId: null,
blockedServerIds: [],
playQueueId: null,
});
export default state;