Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
- [diegoeche](https://github.com/diegoeche)
- [Free O'Toole](https://github.com/freeotoole)
- [TheBosZ](https://github.com/thebosz)
- [qm3jp](https://github.com/qm3jp)

## Emby Contributors

Expand Down
77 changes: 45 additions & 32 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind.js';
import { PlaybackErrorCode } from '@jellyfin/sdk/lib/generated-client/models/playback-error-code.js';
import { getMediaInfoApi } from '@jellyfin/sdk/lib/utils/api/media-info-api';
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
import { ItemFilter } from '@jellyfin/sdk/lib/generated-client/models/item-filter';
import { ItemSortBy } from '@jellyfin/sdk/lib/generated-client/models/item-sort-by';
import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type';
import { PlaybackErrorCode } from '@jellyfin/sdk/lib/generated-client/models/playback-error-code';
import { getMediaInfoApi } from '@jellyfin/sdk/lib/utils/api/media-info-api';
import merge from 'lodash-es/merge';
import Screenfull from 'screenfull';

Expand Down Expand Up @@ -166,9 +168,9 @@ function createStreamInfoFromUrlItem(item) {
function mergePlaybackQueries(obj1, obj2) {
const query = merge({}, obj1, obj2);

const filters = query.Filters ? query.Filters.split(',') : [];
if (filters.indexOf('IsNotFolder') === -1) {
filters.push('IsNotFolder');
const filters = query.Filters?.split(',') || [];
if (!filters.includes(ItemFilter.IsNotFolder)) {
filters.push(ItemFilter.IsNotFolder);
}
query.Filters = filters.join(',');
return query;
Expand Down Expand Up @@ -1828,64 +1830,75 @@ export class PlaybackManager {
}

function getPlaybackPromise(firstItem, serverId, options, queryOptions, items) {
const SortBy = options.shuffle ? ItemSortBy.Random : ItemSortBy.SortName;

switch (firstItem.Type) {
case 'Program':
case BaseItemKind.Program:
return getItemsForPlayback(serverId, {
Ids: firstItem.ChannelId
});
case 'Playlist':
case BaseItemKind.Playlist:
return getItemsForPlayback(serverId, {
ParentId: firstItem.Id,
SortBy: options.shuffle ? 'Random' : null
SortBy: options.shuffle ? SortBy : undefined
});
case 'MusicArtist':
case BaseItemKind.MusicArtist:

return getItemsForPlayback(serverId, mergePlaybackQueries({
ArtistIds: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'Album,ParentIndexNumber,IndexNumber,SortName',
MediaTypes: 'Audio'
SortBy: options.shuffle ? SortBy : [
ItemSortBy.Album,
ItemSortBy.ParentIndexNumber,
ItemSortBy.IndexNumber,
ItemSortBy.SortName
].join(','),
MediaTypes: MediaType.Audio
}, queryOptions));
case 'PhotoAlbum':
case BaseItemKind.PhotoAlbum:
return getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.Id,
Filters: 'IsNotFolder',
// Setting this to true may cause some incorrect sorting
Recursive: false,
SortBy: options.shuffle ? 'Random' : 'SortName',
SortBy,
// Only include Photos because we do not handle mixed queues currently
MediaTypes: 'Photo',
MediaTypes: MediaType.Photo,
Limit: UNLIMITED_ITEMS
}, queryOptions));
case 'MusicGenre':
case BaseItemKind.MusicGenre:
return getItemsForPlayback(serverId, mergePlaybackQueries({
GenreIds: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Audio'
SortBy,
MediaTypes: MediaType.Audio
}, queryOptions));
case 'Genre':
case BaseItemKind.Genre:
return getItemsForPlayback(serverId, mergePlaybackQueries({
GenreIds: firstItem.Id,
ParentId: firstItem.ParentId,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Video'
SortBy,
MediaTypes: MediaType.Video
}, queryOptions));
case 'Studio':
case BaseItemKind.Studio:
return getItemsForPlayback(serverId, mergePlaybackQueries({
StudioIds: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Video'
SortBy,
MediaTypes: MediaType.Video
}, queryOptions));
case BaseItemKind.Person:
return getItemsForPlayback(serverId, mergePlaybackQueries({
PersonIds: firstItem.Id,
ParentId: firstItem.ParentId,
Recursive: true,
SortBy,
MediaTypes: MediaType.Video
}, queryOptions));
case 'Series':
case 'Season':
case BaseItemKind.Series:
case BaseItemKind.Season:
return getSeriesOrSeasonPlaybackPromise(firstItem, options, items);
case 'Episode':
case BaseItemKind.Episode:
return getEpisodePlaybackPromise(firstItem, options, items);
}

Expand Down
Loading