refactor: rewrite video player
This commit is contained in:
34 files changed
+3766
-3007
No files matched your search
+3
-1
@@ -39,4 +39,6 @@ target/
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
generateBanner
|
||||
generateBanner
|
||||
# Million Lint
|
||||
.million
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"encodings":["src\\main.tsx","ProviderWrapper",[52,0,71,1],[53,39,57,3],[53,8,53,11],[53,13,53,22],[53,24,53,35],[58,34,61,3],[58,8,58,12],[58,14,58,30],[66,2,69,4],"src\\components\\notices\\errorNotice\\errorNotice.tsx","ErrorNotice",[6,27,54,1],[6,28,6,56],[9,2,52,8],[20,3,31,9],[32,3,34,16],[35,3,51,16],"src\\utils\\store\\api.tsx","ApiProvider",[50,27,67,1],[50,28,50,65],[51,17,65,2],[66,8,66,75],"useApiInContext",[69,7,75,1],[70,15,70,37],[74,8,74,57],"src\\utils\\store\\central.tsx","CentralProvider",[48,31,71,1],[48,32,48,69],[49,17,67,2],[69,2,69,77],"useCentralStore",[73,7,79,1],[74,15,74,41],[78,8,78,57],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[88,0,918,1],[89,13,89,42],[90,21,90,32],[90,9,90,16],[91,39,91,54],[92,16,92,48],[94,14,94,51],[106,5,116,3],[97,2,97,16],[98,2,98,6],[99,2,99,10],[100,2,100,14],[101,2,101,15],[102,2,102,14],[103,2,103,13],[104,2,104,15],[105,2,105,11],[117,40,120,3],[117,8,117,29],[117,31,117,36],[122,31,122,45],[123,41,125,2],[127,51,127,66],[130,31,130,46],[131,31,131,45],[132,35,132,50],[133,45,133,68],[134,33,134,56],[135,43,135,58],[137,29,137,40],[138,27,138,42],[140,1,140,41],[142,41,142,72],[219,24,257,7],[259,1,267,21],[267,5,267,19],[269,1,287,7],[289,1,292,15],[292,5,292,13],[294,41,311,62],[311,5,311,31],[311,33,311,60],[313,1,334,3],[331,2,331,28],[332,2,332,29],[333,2,333,37],[336,29,344,15],[344,5,344,13],[346,24,364,25],[364,5,364,13],[364,15,364,23],[366,25,370,15],[370,5,370,13],[372,49,372,64],[373,27,375,7],[376,1,376,56],[376,46,376,54],[378,22,384,21],[384,5,384,19],[464,5,481,11],[465,6,474,8],[475,6,477,19],[478,6,480,19],[485,4,499,10],[486,5,495,7],[496,5,498,18],[504,4,511,10],[505,5,507,18],[508,5,510,18],[515,3,519,9],[516,4,518,17],[523,51,523,66],[524,1,530,13],[530,5,530,11],[542,2,916,8],[543,3,566,21],[545,5,564,18],[563,6,563,52],[568,4,582,13],[585,4,585,55],[587,3,605,21],[589,5,603,18],[595,6,597,12],[598,6,602,8],[606,3,883,16],[642,4,696,10],[643,5,645,18],[644,6,644,66],[646,5,648,18],[647,6,647,64],[649,5,695,12],[670,6,694,18],[686,7,688,18],[690,8,692,19],[698,5,881,11],[699,6,706,19],[702,8,704,21],[707,6,880,12],[708,7,763,13],[709,8,756,10],[757,8,762,14],[758,9,760,22],[761,9,761,62],[764,7,879,13],[765,8,800,14],[766,9,766,31],[767,9,777,22],[774,10,776,17],[778,9,782,22],[779,10,781,17],[783,9,793,22],[790,10,792,17],[794,9,794,27],[795,9,799,22],[801,8,878,14],[802,9,840,22],[824,10,826,23],[827,10,839,12],[841,9,854,22],[847,10,853,17],[855,9,855,24],[856,9,865,22],[860,10,864,17],[866,9,877,22],[874,10,876,17],[884,3,915,5],"sliderDisplayFormat",[386,29,521,2],"src\\routes\\_api\\home\\index.tsx","Home",[40,0,400,1],[41,13,41,42],[42,14,42,51],[44,19,54,3],[56,21,80,3],[82,26,96,3],[98,26,111,3],[113,21,130,3],[132,47,134,6],[136,18,136,31],[138,21,138,59],[140,24,142,2],[144,1,157,26],[157,5,157,24],[161,3,397,10],[168,4,208,20],[170,6,170,26],[173,7,205,9],[210,4,245,20],[212,6,214,12],[213,7,213,51],[218,6,218,23],[220,6,243,21],[224,10,240,12],[246,4,301,20],[248,6,250,12],[249,7,249,52],[254,6,254,23],[258,6,299,21],[261,9,296,11],[302,4,354,20],[304,6,306,12],[305,7,305,59],[310,6,310,23],[315,6,352,21],[318,9,349,11],[355,4,385,20],[357,6,359,12],[358,7,358,59],[363,6,363,23],[368,6,383,21],[371,9,380,11],[386,4,396,20],[388,6,390,12],[389,7,389,62],[394,13,394,69],"src\\routes\\_api\\search\\index.jsx","SearchPage",[32,0,386,1],[33,13,33,36],[35,18,35,31],[36,19,36,36],[36,9,36,14],[38,37,38,49],[41,14,41,51],[45,16,58,3],[59,16,72,3],[73,20,86,3],[87,15,100,3],[101,14,114,3],[115,22,128,3],[129,16,140,3],[141,18,153,3],[155,23,155,71],[155,8,155,19],[157,1,160,7],[162,2,384,8],[172,3,203,9],[173,4,194,6],[195,4,202,10],[201,5,201,61],[204,3,358,9],[210,5,229,20],[212,7,227,9],[232,5,257,20],[234,7,255,9],[260,5,274,20],[263,8,271,10],[277,5,290,20],[279,7,288,9],[293,5,307,20],[295,7,305,9],[310,5,324,20],[312,7,322,9],[327,5,340,20],[329,7,338,9],[343,5,356,20],[345,7,354,9],[375,5,381,11],[380,6,380,68],[383,3,383,13],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[21,0,297,1],[22,13,22,36],[23,23,23,71],[23,8,23,19],[25,14,25,51],[27,16,38,3],[40,16,51,3],[53,20,64,3],[66,15,77,3],[79,14,90,3],[92,22,103,3],[105,16,116,3],[118,1,120,3],[123,2,295,9],[134,4,153,19],[136,6,151,8],[156,4,181,19],[158,6,179,8],[184,4,203,19],[186,6,201,8],[206,4,226,19],[208,6,224,8],[229,4,249,19],[231,6,247,8],[252,4,271,19],[254,6,269,8],[274,4,293,19],[276,6,291,8],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,206,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[31,9,31,24],[33,19,33,54],[35,21,35,37],[37,17,40,3],[42,23,45,3],[47,28,65,3],[90,1,92,7],[95,2,204,8],[96,3,96,21],[97,3,117,9],[106,4,108,17],[109,4,116,17],[115,5,115,56],[118,3,203,11],[121,6,201,12],[122,7,124,13],[125,7,173,13],[126,8,154,21],[136,10,152,12],[138,12,144,25],[155,8,163,21],[164,8,172,21],[174,7,200,13],[175,8,186,21],[185,9,185,62],[187,8,199,21],[198,9,198,71],"src\\routes\\setup\\server.add.tsx","ServerSetup",Line truncated
|
||||
{"encodings":["src\\main.tsx","ProviderWrapper",[52,0,71,1],[53,39,57,3],[53,8,53,11],[53,13,53,22],[53,24,53,35],[58,34,61,3],[58,8,58,12],[58,14,58,30],[66,2,69,4],"src\\components\\notices\\errorNotice\\errorNotice.tsx","ErrorNotice",[6,27,54,1],[6,28,6,56],[9,2,52,8],[20,3,31,9],[32,3,34,16],[35,3,51,16],"src\\utils\\store\\api.tsx","ApiProvider",[50,27,67,1],[50,28,50,65],[51,17,65,2],[66,8,66,75],"useApiInContext",[69,7,75,1],[70,15,70,37],[74,8,74,57],"src\\utils\\store\\central.tsx","CentralProvider",[48,31,71,1],[48,32,48,69],[49,17,67,2],[69,2,69,77],"useCentralStore",[73,7,79,1],[74,15,74,41],[78,8,78,57],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[88,0,918,1],[89,13,89,42],[90,21,90,32],[90,9,90,16],[91,39,91,54],[92,16,92,48],[94,14,94,51],[106,5,116,3],[97,2,97,16],[98,2,98,6],[99,2,99,10],[100,2,100,14],[101,2,101,15],[102,2,102,14],[103,2,103,13],[104,2,104,15],[105,2,105,11],[117,40,120,3],[117,8,117,29],[117,31,117,36],[122,31,122,45],[123,41,125,2],[127,51,127,66],[130,31,130,46],[131,31,131,45],[132,35,132,50],[133,45,133,68],[134,33,134,56],[135,43,135,58],[137,29,137,40],[138,27,138,42],[140,1,140,41],[142,41,142,72],[219,24,257,7],[259,1,267,21],[267,5,267,19],[269,1,287,7],[289,1,292,15],[292,5,292,13],[294,41,311,62],[311,5,311,31],[311,33,311,60],[313,1,334,3],[331,2,331,28],[332,2,332,29],[333,2,333,37],[336,29,344,15],[344,5,344,13],[346,24,364,25],[364,5,364,13],[364,15,364,23],[366,25,370,15],[370,5,370,13],[372,49,372,64],[373,27,375,7],[376,1,376,56],[376,46,376,54],[378,22,384,21],[384,5,384,19],[464,5,481,11],[465,6,474,8],[475,6,477,19],[478,6,480,19],[485,4,499,10],[486,5,495,7],[496,5,498,18],[504,4,511,10],[505,5,507,18],[508,5,510,18],[515,3,519,9],[516,4,518,17],[523,51,523,66],[524,1,530,13],[530,5,530,11],[542,2,916,8],[543,3,566,21],[545,5,564,18],[563,6,563,52],[568,4,582,13],[585,4,585,55],[587,3,605,21],[589,5,603,18],[595,6,597,12],[598,6,602,8],[606,3,883,16],[642,4,696,10],[643,5,645,18],[644,6,644,66],[646,5,648,18],[647,6,647,64],[649,5,695,12],[670,6,694,18],[686,7,688,18],[690,8,692,19],[698,5,881,11],[699,6,706,19],[702,8,704,21],[707,6,880,12],[708,7,763,13],[709,8,756,10],[757,8,762,14],[758,9,760,22],[761,9,761,62],[764,7,879,13],[765,8,800,14],[766,9,766,31],[767,9,777,22],[774,10,776,17],[778,9,782,22],[779,10,781,17],[783,9,793,22],[790,10,792,17],[794,9,794,27],[795,9,799,22],[801,8,878,14],[802,9,840,22],[824,10,826,23],[827,10,839,12],[841,9,854,22],[847,10,853,17],[855,9,855,24],[856,9,865,22],[860,10,864,17],[866,9,877,22],[874,10,876,17],[884,3,915,5],"sliderDisplayFormat",[386,29,521,2],"src\\routes\\_api\\home\\index.tsx","Home",[40,0,400,1],[41,13,41,42],[42,14,42,51],[44,19,54,3],[56,21,80,3],[82,26,96,3],[98,26,111,3],[113,21,130,3],[132,47,134,6],[136,18,136,31],[138,21,138,59],[140,24,142,2],[144,1,157,26],[157,5,157,24],[161,3,397,10],[168,4,208,20],[170,6,170,26],[173,7,205,9],[210,4,245,20],[212,6,214,12],[213,7,213,51],[218,6,218,23],[220,6,243,21],[224,10,240,12],[246,4,301,20],[248,6,250,12],[249,7,249,52],[254,6,254,23],[258,6,299,21],[261,9,296,11],[302,4,354,20],[304,6,306,12],[305,7,305,59],[310,6,310,23],[315,6,352,21],[318,9,349,11],[355,4,385,20],[357,6,359,12],[358,7,358,59],[363,6,363,23],[368,6,383,21],[371,9,380,11],[386,4,396,20],[388,6,390,12],[389,7,389,62],[394,13,394,69],"src\\routes\\_api\\search\\index.jsx","SearchPage",[32,0,386,1],[33,13,33,36],[35,18,35,31],[36,19,36,36],[36,9,36,14],[38,37,38,49],[41,14,41,51],[45,16,58,3],[59,16,72,3],[73,20,86,3],[87,15,100,3],[101,14,114,3],[115,22,128,3],[129,16,140,3],[141,18,153,3],[155,23,155,71],[155,8,155,19],[157,1,160,7],[162,2,384,8],[172,3,203,9],[173,4,194,6],[195,4,202,10],[201,5,201,61],[204,3,358,9],[210,5,229,20],[212,7,227,9],[232,5,257,20],[234,7,255,9],[260,5,274,20],[263,8,271,10],[277,5,290,20],[279,7,288,9],[293,5,307,20],[295,7,305,9],[310,5,324,20],[312,7,322,9],[327,5,340,20],[329,7,338,9],[343,5,356,20],[345,7,354,9],[375,5,381,11],[380,6,380,68],[383,3,383,13],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[21,0,297,1],[22,13,22,36],[23,23,23,71],[23,8,23,19],[25,14,25,51],[27,16,38,3],[40,16,51,3],[53,20,64,3],[66,15,77,3],[79,14,90,3],[92,22,103,3],[105,16,116,3],[118,1,120,3],[123,2,295,9],[134,4,153,19],[136,6,151,8],[156,4,181,19],[158,6,179,8],[184,4,203,19],[186,6,201,8],[206,4,226,19],[208,6,224,8],[229,4,249,19],[231,6,247,8],[252,4,271,19],[254,6,269,8],[274,4,293,19],[276,6,291,8],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,206,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[31,9,31,24],[33,19,33,54],[35,21,35,37],[37,17,40,3],[42,23,45,3],[47,28,65,3],[90,1,92,7],[95,2,204,8],[96,3,96,21],[97,3,117,9],[106,4,108,17],[109,4,116,17],[115,5,115,56],[118,3,203,11],[121,6,201,12],[122,7,124,13],[125,7,173,13],[126,8,154,21],[136,10,152,12],[138,12,144,25],[155,8,163,21],[164,8,172,21],[174,7,200,13],[175,8,186,21],[185,9,185,62],[187,8,199,21],[198,9,198,71],"src\\routes\\setup\\server.add.tsx","ServerSetup",Line truncated
|
||||
+22
-16
@@ -1,19 +1,27 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
|
||||
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"useEnumInitializers": "off"
|
||||
"useEnumInitializers": "off",
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
},
|
||||
"a11y": {
|
||||
"useKeyWithClickEvents": "off",
|
||||
"useMediaCaption": "off"
|
||||
"useMediaCaption": "off",
|
||||
"noStaticElementInteractions": "off"
|
||||
},
|
||||
"correctness": {
|
||||
"useExhaustiveDependencies": "off",
|
||||
@@ -22,19 +30,17 @@
|
||||
"suspicious": {
|
||||
"noExplicitAny": "off"
|
||||
},
|
||||
"nursery": {
|
||||
"useComponentExportOnlyModules": "error"
|
||||
}
|
||||
"nursery": {}
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.jsx",
|
||||
"src/**/*.js",
|
||||
"*.json",
|
||||
"*.scss"
|
||||
"includes": [
|
||||
"**/src/**/*.ts",
|
||||
"**/src/**/*.tsx",
|
||||
"**/src/**/*.jsx",
|
||||
"**/src/**/*.js",
|
||||
"**/*.json",
|
||||
"**/*.scss"
|
||||
],
|
||||
"ignoreUnknown": true
|
||||
},
|
||||
|
||||
+35
-35
@@ -19,45 +19,45 @@
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.2.5",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.2.6",
|
||||
"@fontsource-variable/noto-sans": "^5.2.7",
|
||||
"@fontsource-variable/plus-jakarta-sans": "^5.2.5",
|
||||
"@fontsource-variable/space-grotesk": "^5.2.7",
|
||||
"@fontsource-variable/plus-jakarta-sans": "^5.2.6",
|
||||
"@fontsource-variable/space-grotesk": "^5.2.8",
|
||||
"@jellyfin/sdk": "0.11.0",
|
||||
"@million/lint": "^1.0.14",
|
||||
"@mui/lab": "7.0.0-beta.12",
|
||||
"@mui/material": "7.1.0",
|
||||
"@mui/lab": "7.0.0-beta.14",
|
||||
"@mui/material": "7.1.2",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@react-spring/web": "^10.0.1",
|
||||
"@tanem/react-nprogress": "^5.0.55",
|
||||
"@tanstack/react-form": "^1.12.0",
|
||||
"@tanstack/react-query": "^5.79.0",
|
||||
"@tanstack/react-query-devtools": "^5.79.0",
|
||||
"@tanstack/react-router": "^1.120.13",
|
||||
"@tanstack/react-router-devtools": "^1.120.13",
|
||||
"@tanstack/react-virtual": "^3.13.9",
|
||||
"@tauri-apps/api": "2.5.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
||||
"@tanstack/react-form": "^1.12.3",
|
||||
"@tanstack/react-query": "^5.81.2",
|
||||
"@tanstack/react-query-devtools": "^5.81.2",
|
||||
"@tanstack/react-router": "^1.121.34",
|
||||
"@tanstack/react-router-devtools": "^1.121.34",
|
||||
"@tanstack/react-virtual": "^3.13.11",
|
||||
"@tauri-apps/api": "2.6.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.2.3",
|
||||
"@tauri-apps/plugin-dialog": "2.2.2",
|
||||
"@tauri-apps/plugin-notification": "2.2.2",
|
||||
"@tauri-apps/plugin-process": "2.2.1",
|
||||
"@tauri-apps/plugin-notification": "2.2.3",
|
||||
"@tauri-apps/plugin-process": "2.2.2",
|
||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||
"@tauri-apps/plugin-updater": "2.7.1",
|
||||
"@tauri-apps/plugin-upload": "2.2.1",
|
||||
"@tauri-apps/plugin-window-state": "~2.2.2",
|
||||
"@types/node": "^22.15.28",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"axios": "^1.9.0",
|
||||
"@tauri-apps/plugin-updater": "2.8.1",
|
||||
"@tauri-apps/plugin-upload": "2.2.2",
|
||||
"@tauri-apps/plugin-window-state": "~2.2.3",
|
||||
"@types/node": "^24.0.4",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"axios": "^1.10.0",
|
||||
"axios-tauri-api-adapter": "^2.0.6",
|
||||
"blurhash": "^2.0.5",
|
||||
"immer": "^10.1.1",
|
||||
"jassub": "^1.8.4",
|
||||
"jassub": "^1.8.6",
|
||||
"libpgs": "^0.8.1",
|
||||
"lodash": "^4.17.21",
|
||||
"material-symbols": "^0.31.4",
|
||||
"material-symbols": "^0.31.9",
|
||||
"million": "^3.1.11",
|
||||
"motion": "^12.15.0",
|
||||
"motion": "^12.19.1",
|
||||
"notistack": "^3.0.2",
|
||||
"react": "^19.1.0",
|
||||
"react-blurhash": "^0.3.0",
|
||||
@@ -72,23 +72,23 @@
|
||||
"remark-gfm": "^4.0.1",
|
||||
"typescript": "^5.8.3",
|
||||
"vite-plugin-svgr": "^4.3.0",
|
||||
"wavesurfer.js": "^7.9.5",
|
||||
"wavesurfer.js": "^7.9.8",
|
||||
"zustand": "5.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.27.1",
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@tanstack/router-cli": "^1.120.13",
|
||||
"@tanstack/router-devtools": "^1.120.13",
|
||||
"@tanstack/router-vite-plugin": "^1.120.13",
|
||||
"@tauri-apps/cli": "2.5.0",
|
||||
"@types/lodash": "^4.17.17",
|
||||
"@vitejs/plugin-react": "^4.5.0",
|
||||
"@biomejs/biome": "^2.0.5",
|
||||
"@tanstack/router-cli": "^1.121.34",
|
||||
"@tanstack/router-devtools": "^1.121.34",
|
||||
"@tanstack/router-vite-plugin": "^1.121.34",
|
||||
"@tauri-apps/cli": "2.6.0",
|
||||
"@types/lodash": "^4.17.18",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
||||
"eslint-plugin-react-hooks": "6.0.0-rc1",
|
||||
"prop-types": "^15.8.1",
|
||||
"sass": "^1.89.0",
|
||||
"vite": "^6.3.5"
|
||||
"sass": "^1.89.2",
|
||||
"vite": "^7.0.0"
|
||||
},
|
||||
"license": "GPL-3.0-only"
|
||||
}
|
||||
Generated
+851
-787
File diff suppressed because it is too large.
Load diff
Generated
+410
-281
File diff suppressed because it is too large.
Load diff
@@ -1 +1 @@
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":[Line truncated
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":[Line truncated
|
||||
@@ -37,7 +37,7 @@
|
||||
],
|
||||
"definitions": {
|
||||
"Capability": {
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
@@ -49,7 +49,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description of what the capability is intended to allow on associated windows.\n\nIt should contain a description of what the grouped permissions should allow.\n\n## Example\n\nThis capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.",
|
||||
"description": "Description of what the capability is intended to allow on associated windows.\n\nIt should contain a description of what the grouped permissions should allow.\n\n## Example\n\nThis capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1094,6 +1094,12 @@
|
||||
"const": "core:webview:allow-reparent",
|
||||
"markdownDescription": "Enables the reparent command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_webview_auto_resize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:webview:allow-set-webview-auto-resize",
|
||||
"markdownDescription": "Enables the set_webview_auto_resize command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_webview_background_color command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1196,6 +1202,12 @@
|
||||
"const": "core:webview:deny-reparent",
|
||||
"markdownDescription": "Denies the reparent command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_webview_auto_resize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:webview:deny-set-webview-auto-resize",
|
||||
"markdownDescription": "Denies the set_webview_auto_resize command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_webview_background_color command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
],
|
||||
"definitions": {
|
||||
"Capability": {
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"description": "A grouping and boundary mechanism developers can use to isolate access to the IPC layer.\n\nIt controls application windows' and webviews' fine grained access to the Tauri core, application, or plugin commands. If a webview or its window is not matching any capability then it has no access to the IPC layer at all.\n\nThis can be done to create groups of windows, based on their required system access, which can reduce impact of frontend vulnerabilities in less privileged windows. Windows can be added to a capability by exact name (e.g. `main-window`) or glob patterns like `*` or `admin-*`. A Window can have none, one, or multiple associated capabilities.\n\n## Example\n\n```json { \"identifier\": \"main-user-files-write\", \"description\": \"This capability allows the `main` window on macOS and Windows access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.\", \"windows\": [ \"main\" ], \"permissions\": [ \"core:default\", \"dialog:open\", { \"identifier\": \"fs:allow-write-text-file\", \"allow\": [{ \"path\": \"$HOME/test.txt\" }] }, ], \"platforms\": [\"macOS\",\"windows\"] } ```",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier",
|
||||
@@ -49,7 +49,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description of what the capability is intended to allow on associated windows.\n\nIt should contain a description of what the grouped permissions should allow.\n\n## Example\n\nThis capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programatic access to files selected by the user.",
|
||||
"description": "Description of what the capability is intended to allow on associated windows.\n\nIt should contain a description of what the grouped permissions should allow.\n\n## Example\n\nThis capability allows the `main` window access to `filesystem` write related commands and `dialog` commands to enable programmatic access to files selected by the user.",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1094,6 +1094,12 @@
|
||||
"const": "core:webview:allow-reparent",
|
||||
"markdownDescription": "Enables the reparent command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_webview_auto_resize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:webview:allow-set-webview-auto-resize",
|
||||
"markdownDescription": "Enables the set_webview_auto_resize command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_webview_background_color command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1196,6 +1202,12 @@
|
||||
"const": "core:webview:deny-reparent",
|
||||
"markdownDescription": "Denies the reparent command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_webview_auto_resize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:webview:deny-set-webview-auto-resize",
|
||||
"markdownDescription": "Denies the set_webview_auto_resize command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_webview_background_color command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
export default function Backdrop() {
|
||||
const [backdropLoading, setBackdropLoading] = useState(true);
|
||||
|
||||
|
||||
const [backdropId, backdropUrl] = useBackdropStore((state) => [
|
||||
state.backdropId,
|
||||
state.backdropUrl,
|
||||
]);
|
||||
|
||||
|
||||
// Reset loading status for backdrop
|
||||
useLayoutEffect(() => {
|
||||
setBackdropLoading(true);
|
||||
}, [backdropId]);
|
||||
|
||||
|
||||
if (!backdropUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app-backdrop-container">
|
||||
<AnimatePresence>
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
import React, { memo, type MouseEvent } from "react"; // Import memo
|
||||
|
||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||
import Fab from "@mui/material/Fab";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
type BaseItemDtoQueryResult,
|
||||
@@ -17,31 +9,34 @@ import {
|
||||
type PlaybackInfoResponse,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||
import Fab from "@mui/material/Fab";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
|
||||
import { playItem } from "@/utils/store/playback";
|
||||
|
||||
import React, { type MouseEvent, memo } from "react"; // Import memo
|
||||
import type PlayResult from "@//utils/types/playResult";
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||
import playbackProfile from "@/utils/playback-profiles";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||
import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { playItem } from "@/utils/store/playback";
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
|
||||
type PlayButtonProps = {
|
||||
item: BaseItemDto;
|
||||
@@ -89,7 +84,7 @@ const PlayButton = ({
|
||||
itemType,
|
||||
currentAudioTrack,
|
||||
currentSubTrack,
|
||||
currentVideoTrack,
|
||||
// currentVideoTrack,
|
||||
className,
|
||||
sx,
|
||||
buttonProps,
|
||||
@@ -574,26 +569,46 @@ const PlayButton = ({
|
||||
initVolume = displayPreferences.data.CustomPrefs?.Volume;
|
||||
}
|
||||
|
||||
playItem(
|
||||
itemName,
|
||||
episodeTitle,
|
||||
currentVideoTrack ?? 0,
|
||||
Number(result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex),
|
||||
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
||||
playbackUrl,
|
||||
userId ?? "",
|
||||
startPosition,
|
||||
result?.item?.Items?.[episodeIndex].RunTimeTicks,
|
||||
playItemValue ?? item,
|
||||
queue,
|
||||
episodeIndex,
|
||||
result?.mediaSource?.MediaSources?.[0]?.Id,
|
||||
result?.mediaSource?.PlaySessionId,
|
||||
subtitle,
|
||||
result?.mediaSegments,
|
||||
audio,
|
||||
Number(initVolume),
|
||||
);
|
||||
const videoTrack =
|
||||
result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||
(value) => value.Type === "Video",
|
||||
);
|
||||
|
||||
playItem({
|
||||
metadata: {
|
||||
itemName: itemName ?? "",
|
||||
episodeTitle: episodeTitle,
|
||||
isEpisode: !!item.SeriesId,
|
||||
itemDuration: item.RunTimeTicks ?? 0,
|
||||
item: playItemValue ?? item,
|
||||
mediaSegments: result.mediaSegments,
|
||||
userDataLastPlayedPositionTicks: startPosition ?? 0,
|
||||
},
|
||||
mediaSource: {
|
||||
videoTrack: videoTrack?.[0]?.Index ?? 0,
|
||||
audioTrack: audio.track,
|
||||
container: result.mediaSource.MediaSources?.[0].Container ?? "",
|
||||
id: result.mediaSource.MediaSources?.[0]?.Id,
|
||||
subtitle: {
|
||||
url: subtitle?.url,
|
||||
track: subtitle?.track ?? -1,
|
||||
format: subtitle?.format ?? "nosub",
|
||||
allTracks:
|
||||
result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||
(value) => value.Type === "Subtitle",
|
||||
),
|
||||
enable: subtitle?.enable ?? false,
|
||||
},
|
||||
audio: audio,
|
||||
},
|
||||
playbackStream: playbackUrl,
|
||||
playsessionId: result.mediaSource.PlaySessionId,
|
||||
userDataPlayedPositionTicks:
|
||||
item.UserData?.PlaybackPositionTicks ?? 0,
|
||||
userId,
|
||||
queueItems: queue ?? [],
|
||||
queueItemIndex: episodeIndex,
|
||||
});
|
||||
navigate({ to: "/player" });
|
||||
}
|
||||
},
|
||||
@@ -686,7 +701,7 @@ const PlayButton = ({
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<LoadingButton
|
||||
<Button
|
||||
loading={currentEpisode.isPending}
|
||||
className={className ?? "play-button"}
|
||||
variant="contained"
|
||||
@@ -725,7 +740,7 @@ const PlayButton = ({
|
||||
: 0
|
||||
}
|
||||
/>
|
||||
</LoadingButton>
|
||||
</Button>
|
||||
{(currentEpisode.data?.Items?.[0].UserData?.PlaybackPositionTicks ??
|
||||
0) > 0 && (
|
||||
<Typography
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const LoadingIndicator = () => {
|
||||
const { isBuffering } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isBuffering: state.playerState.isBuffering,
|
||||
})),
|
||||
);
|
||||
if (!isBuffering) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
zIndex: 2,
|
||||
position: "absolute",
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
top: 0,
|
||||
left: 0,
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<CircularProgress size={72} thickness={1.4} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default LoadingIndicator;
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import ticksDisplay from "@/utils/methods/ticksDisplay";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ProgressDislay = () => {
|
||||
const { currentTime, itemDuration, isUserSeeking, seekValue } =
|
||||
usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
currentTime: state.playerState.currentTime,
|
||||
itemDuration: state.metadata.itemDuration,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
seekValue: state.playerState.seekValue,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<div className="video-player-osd-controls-timeline-text">
|
||||
<Typography>
|
||||
{ticksDisplay(isUserSeeking ? (seekValue ?? 0) : (currentTime ?? 0))}
|
||||
</Typography>
|
||||
<Typography>{ticksDisplay(itemDuration)}</Typography>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgressDislay;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { LinearProgress } from "@mui/material";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const VolumeChangeOverlay = () => {
|
||||
const { playerVolume, showVolumeIndicator } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
playerVolume: state.playerState.volume,
|
||||
showVolumeIndicator: state.isVolumeInidcatorVisible,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{showVolumeIndicator && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
className="video-volume-indicator glass"
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
{playerVolume > 0.7 ? "volume_up" : "volume_down"}
|
||||
</div>
|
||||
<LinearProgress
|
||||
style={{ width: "100%" }}
|
||||
value={playerVolume * 100}
|
||||
variant="determinate"
|
||||
/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
};
|
||||
export default VolumeChangeOverlay;
|
||||
+66
-90
@@ -1,46 +1,11 @@
|
||||
import { ticksToMs, ticksToSec } from "@/utils/date/time";
|
||||
import {
|
||||
type VideoPlayerAction,
|
||||
VideoPlayerActionKind,
|
||||
} from "@/utils/reducers/videoPlayerReducer";
|
||||
import type audioPlaybackInfo from "@/utils/types/audioPlaybackInfo";
|
||||
import type subtitlePlaybackInfo from "@/utils/types/subtitlePlaybackInfo";
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type {
|
||||
BaseItemDto,
|
||||
TrickplayInfo,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import type { TrickplayInfo } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Slider, Tooltip, Typography } from "@mui/material";
|
||||
import type { Instance } from "@popperjs/core";
|
||||
import React, {
|
||||
type RefObject,
|
||||
type ActionDispatch,
|
||||
type MouseEvent,
|
||||
} from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import type ReactPlayer from "react-player";
|
||||
|
||||
type BubbleSliderProps = {
|
||||
itemDuration: number;
|
||||
item: BaseItemDto;
|
||||
mediaSource: {
|
||||
videoTrack: number;
|
||||
audioTrack: number;
|
||||
container: string;
|
||||
id: string | undefined;
|
||||
subtitle: subtitlePlaybackInfo;
|
||||
audio: audioPlaybackInfo;
|
||||
};
|
||||
api: Api;
|
||||
chapterMarks: { value: number }[];
|
||||
sliderState: {
|
||||
isSeeking: boolean;
|
||||
sliderSeek: number;
|
||||
progress: number;
|
||||
};
|
||||
dispatch: ActionDispatch<[action: VideoPlayerAction]>;
|
||||
player: RefObject<ReactPlayer | null>;
|
||||
};
|
||||
import React, { type MouseEvent, useMemo, useRef, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { ticksToMs } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
@@ -64,16 +29,40 @@ const ticksDisplay = (ticks: number) => {
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
const BubbleSlider = ({
|
||||
itemDuration,
|
||||
item,
|
||||
mediaSource,
|
||||
api,
|
||||
chapterMarks,
|
||||
sliderState,
|
||||
dispatch,
|
||||
player,
|
||||
}: BubbleSliderProps) => {
|
||||
const BubbleSlider = () => {
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const {
|
||||
seekValue,
|
||||
currentTime,
|
||||
isUserSeeking,
|
||||
// setIsUserSeeking,
|
||||
// setSeekValue,
|
||||
// seekTo,
|
||||
itemDuration,
|
||||
itemChapters,
|
||||
mediaSource,
|
||||
itemTrickplay,
|
||||
itemId,
|
||||
handleStartSeek,
|
||||
handleStopSeek,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekValue: state.playerState.seekValue,
|
||||
currentTime: state.playerState.currentTime,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
// setIsUserSeeking: state.setIsUserSeeking,
|
||||
// setSeekValue: state.setSeekValue,
|
||||
// seekTo: state.seekTo,
|
||||
itemDuration: state.metadata.item.RunTimeTicks,
|
||||
itemChapters: state.metadata.item.Chapters,
|
||||
mediaSource: state.mediaSource,
|
||||
itemTrickplay: state.metadata.item.Trickplay,
|
||||
itemId: state.metadata.item.Id,
|
||||
handleStartSeek: state.handleStartSeek,
|
||||
handleStopSeek: state.handleStopSeek,
|
||||
})),
|
||||
);
|
||||
|
||||
const positionRef = useRef<{ x: number; y: number }>({
|
||||
x: 0,
|
||||
y: 0,
|
||||
@@ -89,20 +78,27 @@ const BubbleSlider = ({
|
||||
const width = rect.width;
|
||||
const distX = event.clientX - rect.left;
|
||||
const percentageCovered = distX / width;
|
||||
setHoverProgress(percentageCovered * itemDuration);
|
||||
setHoverProgress(percentageCovered * (itemDuration ?? 0));
|
||||
if (popperRef.current != null) {
|
||||
popperRef.current.update();
|
||||
}
|
||||
};
|
||||
|
||||
const chapterMarks = useMemo(() => {
|
||||
const marks: { value: number }[] = [];
|
||||
itemChapters?.map((val) => {
|
||||
marks.push({ value: val.StartPositionTicks ?? 0 });
|
||||
});
|
||||
return marks;
|
||||
}, [itemChapters]);
|
||||
|
||||
const sliderDisplayFormat = (value: number) => {
|
||||
const currentChapter = item?.Chapters?.filter((chapter, index) => {
|
||||
if (index + 1 === item.Chapters?.length) {
|
||||
const currentChapter = itemChapters?.filter((chapter, index) => {
|
||||
if (index + 1 === itemChapters?.length) {
|
||||
return chapter;
|
||||
}
|
||||
if (
|
||||
(item.Chapters?.[index + 1]?.StartPositionTicks ?? value) - value >=
|
||||
0 &&
|
||||
(itemChapters?.[index + 1]?.StartPositionTicks ?? value) - value >= 0 &&
|
||||
(chapter.StartPositionTicks ?? value) - value < 0
|
||||
) {
|
||||
return chapter;
|
||||
@@ -111,7 +107,7 @@ const BubbleSlider = ({
|
||||
|
||||
let trickplayResolution: TrickplayInfo | undefined;
|
||||
const trickplayResolutions = mediaSource.id
|
||||
? item?.Trickplay?.[mediaSource.id]
|
||||
? itemTrickplay?.[mediaSource.id]
|
||||
: null;
|
||||
if (trickplayResolutions) {
|
||||
let bestWidth: number | undefined;
|
||||
@@ -168,7 +164,7 @@ const BubbleSlider = ({
|
||||
<div
|
||||
className="video-osd-trickplayBubble"
|
||||
style={{
|
||||
background: `url(${api?.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||
width: "100%",
|
||||
@@ -189,7 +185,7 @@ const BubbleSlider = ({
|
||||
<div
|
||||
className="video-osd-trickplayBubble"
|
||||
style={{
|
||||
background: `url(${api?.basePath}/Videos/${item?.Id}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||
background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||
width: "100%",
|
||||
@@ -259,44 +255,24 @@ const BubbleSlider = ({
|
||||
}}
|
||||
>
|
||||
<Slider
|
||||
value={
|
||||
sliderState.isSeeking ? sliderState.sliderSeek : sliderState.progress
|
||||
}
|
||||
max={itemDuration}
|
||||
value={isUserSeeking ? seekValue : currentTime}
|
||||
max={itemDuration ?? 0}
|
||||
step={1}
|
||||
onChange={(_, newValue) => {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_SEEKING,
|
||||
payload: true,
|
||||
});
|
||||
// setIsUserSeeking(true);
|
||||
Array.isArray(newValue)
|
||||
? dispatch({
|
||||
type: VideoPlayerActionKind.SET_SLIDER_SEEK,
|
||||
payload: newValue[0],
|
||||
})
|
||||
: dispatch({
|
||||
type: VideoPlayerActionKind.SET_SLIDER_SEEK,
|
||||
payload: newValue,
|
||||
});
|
||||
? handleStartSeek(newValue[0])
|
||||
: handleStartSeek(newValue);
|
||||
}}
|
||||
onChangeCommitted={(_, newValue) => {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_SEEKING,
|
||||
payload: false,
|
||||
});
|
||||
Array.isArray(newValue)
|
||||
? dispatch({
|
||||
type: VideoPlayerActionKind.SET_SLIDER_SEEK,
|
||||
payload: newValue[0],
|
||||
})
|
||||
: dispatch({
|
||||
type: VideoPlayerActionKind.SET_SLIDER_SEEK,
|
||||
payload: newValue,
|
||||
});
|
||||
// setIsUserSeeking(false);
|
||||
// Array.isArray(newValue)
|
||||
// ? setSeekValue(newValue[0])
|
||||
// : setSeekValue(newValue);
|
||||
if (Array.isArray(newValue)) {
|
||||
player.current?.seekTo(ticksToSec(newValue[0]), "seconds");
|
||||
handleStopSeek(newValue[0]);
|
||||
} else {
|
||||
player.current?.seekTo(ticksToSec(newValue), "seconds");
|
||||
handleStopSeek(newValue);
|
||||
}
|
||||
}}
|
||||
sx={{
|
||||
@@ -0,0 +1,25 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React, { useTransition } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { toggleSubtitleTrack, usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const CaptionsButton = () => {
|
||||
const { subtitle } = usePlaybackStore(
|
||||
useShallow((state) => ({ subtitle: state.mediaSource.subtitle })),
|
||||
);
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
disabled={subtitle?.allTracks?.length === 0 || subtitleIsChanging}
|
||||
onClick={() => startSubtitleChange(toggleSubtitleTrack)}
|
||||
>
|
||||
<span className={"material-symbols-rounded"}>
|
||||
{subtitle?.enable ? "closed_caption" : "closed_caption_disabled"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default CaptionsButton;
|
||||
@@ -0,0 +1,58 @@
|
||||
import { IconButton, Menu, MenuItem } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { ticksToSec } from "@/utils/date/time";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ChaptersListButton = () => {
|
||||
const { itemChapters, seekTo } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
itemChapters: state.metadata.item?.Chapters,
|
||||
seekTo: state.seekTo,
|
||||
})),
|
||||
);
|
||||
const [showChapterList, setShowChapterList] =
|
||||
React.useState<null | HTMLElement>(null);
|
||||
const handleShowChapterList = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setShowChapterList(event.currentTarget);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<IconButton
|
||||
disabled={itemChapters?.length === 0}
|
||||
onClick={handleShowChapterList}
|
||||
>
|
||||
<span className="material-symbols-rounded">list</span>
|
||||
</IconButton>
|
||||
<Menu
|
||||
open={Boolean(showChapterList)}
|
||||
anchorEl={showChapterList}
|
||||
onClose={() => setShowChapterList(null)}
|
||||
anchorOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
>
|
||||
{itemChapters?.length &&
|
||||
itemChapters?.map((chapter) => (
|
||||
<MenuItem
|
||||
key={chapter.Name}
|
||||
onClick={() => {
|
||||
seekTo(ticksToSec(chapter.StartPositionTicks ?? 0));
|
||||
setShowChapterList(null); // Close the chapter list menu
|
||||
}}
|
||||
>
|
||||
{chapter.Name}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChaptersListButton;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ForwardButton = () => {
|
||||
const { seekForward } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekForward: state.seekForward,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<IconButton onClick={() => seekForward(15)}>
|
||||
<span className="material-symbols-rounded fill">fast_forward</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default ForwardButton;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const FullscreenButton = () => {
|
||||
const { isPlayerFullscreen, toggleIsPlayerFullscreen } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isPlayerFullscreen: state.playerState.isPlayerFullscreen,
|
||||
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<IconButton onClick={toggleIsPlayerFullscreen}>
|
||||
<span className="material-symbols-rounded fill">
|
||||
{isPlayerFullscreen ? "fullscreen_exit" : "fullscreen"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default FullscreenButton;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const NextChapterButton = () => {
|
||||
const { seekToNextChapter } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekToNextChapter: state.seekToNextChapter,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<IconButton onClick={() => seekToNextChapter()}>
|
||||
<span className="material-symbols-rounded fill">last_page</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default NextChapterButton;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const PlayPauseButton = () => {
|
||||
const { isPlayerPlaying, toggleIsPlaying } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
toggleIsPlaying: state.toggleIsPlaying,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<IconButton onClick={toggleIsPlaying}>
|
||||
<span className="material-symbols-rounded fill">
|
||||
{isPlayerPlaying ? "pause" : "play_arrow"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayPauseButton;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const PrevChapterButton = () => {
|
||||
const { seekToPrevChapter } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekToPrevChapter: state.seekToPrevChapter,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<IconButton onClick={seekToPrevChapter}>
|
||||
<span className="material-symbols-rounded fill">first_page</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrevChapterButton;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const RewindButton = () => {
|
||||
const { seekBackward } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekBackward: state.seekBackward,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
seekBackward(15);
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded fill">fast_rewind</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default RewindButton;
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Button } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const SkipSegmentButton = () => {
|
||||
const { mediaSegments, currentSegmentIndex, skipSegment } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSegments: state.metadata.mediaSegments,
|
||||
currentSegmentIndex: state.nextSegmentIndex - 1,
|
||||
skipSegment: state.skipSegment,
|
||||
})),
|
||||
);
|
||||
|
||||
if (!mediaSegments?.Items?.length || currentSegmentIndex < 0) {
|
||||
return <></>; // No segments to skip
|
||||
}
|
||||
|
||||
console.log("Current Segment Index:", currentSegmentIndex);
|
||||
console.log("Media Segments:", mediaSegments);
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="large"
|
||||
//@ts-ignore
|
||||
color="white"
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: "18vh",
|
||||
right: "2em",
|
||||
zIndex: 10000,
|
||||
}}
|
||||
onClick={skipSegment}
|
||||
>
|
||||
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default SkipSegmentButton;
|
||||
@@ -0,0 +1,60 @@
|
||||
.video-player {
|
||||
background: black;
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
&-osd {
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: stretch;
|
||||
justify-content: space-between;
|
||||
padding: 1em 2em;
|
||||
background: linear-gradient(to top, rgb(0 0 0 / 0.7) 5vh, transparent 26vh 90vh, rgb(0 0 0 / 0.7));
|
||||
&.hovering {
|
||||
cursor: default;
|
||||
}
|
||||
&-controls {
|
||||
&-timeline-text {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: space-between;
|
||||
}
|
||||
&-progress {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2em;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
margin-bottom: 0.5em;
|
||||
&-bubble {
|
||||
width: 14em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transform-origin: bottom center;
|
||||
transform: translate(var(--left, 0), var(--top, 0));
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
&-buttons {
|
||||
display: flex;
|
||||
gap: 0.4em;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.MuiSlider-valueLabel {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
border-radius: $border-radius-default;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
import { IconButton, Typography } from "@mui/material";
|
||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { motion } from "motion/react";
|
||||
import React, {
|
||||
type MouseEvent,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
||||
import { endsAt, secToTicks } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import CaptionsButton from "./buttons/CaptionsButton";
|
||||
import ChaptersListButton from "./buttons/ChaptersListButton";
|
||||
import ForwardButton from "./buttons/ForwardButton";
|
||||
import FullscreenButton from "./buttons/FullscreenButton";
|
||||
import NextChapterButton from "./buttons/NextChapterButton";
|
||||
import PlayPauseButton from "./buttons/PlayPauseButton";
|
||||
import PrevChapterButton from "./buttons/PrevChapterButton";
|
||||
import RewindButton from "./buttons/RewindButton";
|
||||
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||
|
||||
import "./controls.scss";
|
||||
import { clearQueue } from "@/utils/store/queue";
|
||||
import ProgressDislay from "./ProgressDisplay";
|
||||
|
||||
/**
|
||||
* Constant for the volume change interval when using the mouse wheel.
|
||||
* This value determines how much the volume will change with each scroll step.
|
||||
*/
|
||||
const VOLUME_SCROLL_INTERVAL = 0.02;
|
||||
|
||||
type VideoPlayerControlsProps = {
|
||||
isVisible: boolean;
|
||||
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
};
|
||||
|
||||
const VideoPlayerControls = ({
|
||||
isVisible,
|
||||
onHover,
|
||||
onLeave,
|
||||
}: VideoPlayerControlsProps) => {
|
||||
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const {
|
||||
mediaSourceId,
|
||||
itemId,
|
||||
itemDuration,
|
||||
itemName,
|
||||
episodeTitle,
|
||||
playsessionId,
|
||||
isPlayerPlaying,
|
||||
toggleIsPlaying,
|
||||
toggleIsPlayerFullscreen,
|
||||
isUserSeeking,
|
||||
// seekValue,
|
||||
isPlayerMuted,
|
||||
volume,
|
||||
toggleIsPlayerMuted,
|
||||
increaseVolumeByStep,
|
||||
decreaseVolumeByStep,
|
||||
getCurrentTime,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSourceId: state.mediaSource.id,
|
||||
itemChapters: state.metadata.item.Chapters,
|
||||
itemId: state.metadata.item.Id,
|
||||
itemDuration: state.metadata.itemDuration,
|
||||
itemName: state.metadata.itemName,
|
||||
episodeTitle: state.metadata.episodeTitle,
|
||||
// mediaSegments: state.metadata.mediaSegments,
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
playsessionId: state.playsessionId,
|
||||
toggleIsPlaying: state.toggleIsPlaying,
|
||||
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
seekValue: state.playerState.seekValue,
|
||||
isPlayerMuted: state.playerState.isPlayerMuted,
|
||||
volume: state.playerState.volume,
|
||||
toggleIsPlayerMuted: state.toggleIsPlayerMuted,
|
||||
increaseVolumeByStep: state.increaseVolumeByStep,
|
||||
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
||||
getCurrentTime: state.getCurrentTime,
|
||||
})),
|
||||
);
|
||||
|
||||
// Volume control with mouse wheel
|
||||
useEffect(() => {
|
||||
const handleMouseWheel = (event: WheelEvent) => {
|
||||
if (event.deltaY < 0) {
|
||||
increaseVolumeByStep(VOLUME_SCROLL_INTERVAL);
|
||||
} else if (event.deltaY > 0) {
|
||||
decreaseVolumeByStep(VOLUME_SCROLL_INTERVAL);
|
||||
}
|
||||
};
|
||||
|
||||
const currentRef = playerOSDRef.current;
|
||||
// attach the event listener
|
||||
currentRef?.addEventListener("wheel", handleMouseWheel);
|
||||
|
||||
// remove the event listener
|
||||
return () => {
|
||||
currentRef?.removeEventListener("wheel", handleMouseWheel);
|
||||
};
|
||||
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
||||
|
||||
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
|
||||
|
||||
const [settingsMenuRef, setSettingsMenuRef] =
|
||||
useState<HTMLButtonElement | null>(null);
|
||||
|
||||
// const creditInfo = mediaSegments?.Items?.find(
|
||||
// (segment) => segment.Type === "Outro",
|
||||
// );
|
||||
|
||||
// Credits and Next Episode Card
|
||||
// const [forceShowCredits, setForceShowCredits] = useState(false);
|
||||
// const showUpNextCard = useMemo(() => {
|
||||
// if (queue?.[currentQueueItemIndex]?.Id === queue?.[queue.length - 1]?.Id) {
|
||||
// return false; // Check if the current playing episode is last episode in queue
|
||||
// }
|
||||
// if (creditInfo) {
|
||||
// if (
|
||||
// currentTime >= (creditInfo.StartTicks ?? currentTime + 1) &&
|
||||
// currentTime < (creditInfo.EndTicks ?? 0)
|
||||
// )
|
||||
// return true;
|
||||
// }
|
||||
// if (
|
||||
// Math.ceil(ticksToSec(itemDuration) - ticksToSec(currentTime)) <= 30 &&
|
||||
// Math.ceil(ticksToSec(itemDuration) - ticksToSec(currentTime)) > 0
|
||||
// ) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }, [currentTime, creditInfo, itemDuration, queue, currentQueueItemIndex]);
|
||||
|
||||
const handleExitPlayer = useCallback(async () => {
|
||||
appWindow.getCurrent().setFullscreen(false);
|
||||
|
||||
history.back();
|
||||
if (!api) {
|
||||
throw Error("API is not available, cannot report playback stopped.");
|
||||
}
|
||||
// Report Jellyfin server: Playback has ended/stopped
|
||||
getPlaystateApi(api).reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
ItemId: itemId,
|
||||
MediaSourceId: mediaSourceId,
|
||||
PlaySessionId: playsessionId,
|
||||
PositionTicks: secToTicks(getCurrentTime() ?? 0),
|
||||
},
|
||||
});
|
||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
||||
clearQueue();
|
||||
}, [api, mediaSourceId, playsessionId, itemId]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={
|
||||
isVisible || isUserSeeking || !isPlayerPlaying
|
||||
? "video-player-osd hovering"
|
||||
: "video-player-osd"
|
||||
}
|
||||
onMouseEnter={onHover}
|
||||
onMouseLeave={onLeave}
|
||||
ref={playerOSDRef}
|
||||
initial={{
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: isVisible || isUserSeeking || !isPlayerPlaying ? 1 : 0,
|
||||
}}
|
||||
style={{
|
||||
zIndex: 2,
|
||||
}}
|
||||
onClick={(event) => {
|
||||
if (event.currentTarget !== event.target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.detail === 1) {
|
||||
setClickTimeout(
|
||||
setTimeout(() => {
|
||||
toggleIsPlaying();
|
||||
}, 200),
|
||||
);
|
||||
} else if (event.detail === 2 && clickTimeout) {
|
||||
clearTimeout(clickTimeout);
|
||||
toggleIsPlayerFullscreen();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="video-player-osd-header flex flex-justify-spaced-between flex-align-center">
|
||||
<IconButton onClick={handleExitPlayer}>
|
||||
<span className="material-symbols-rounded">arrow_back</span>
|
||||
</IconButton>
|
||||
<IconButton onClick={(e) => setSettingsMenuRef(e.currentTarget)}>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</IconButton>
|
||||
<VideoPlayerSettingsMenu
|
||||
settingsMenuRef={settingsMenuRef}
|
||||
handleClose={() => setSettingsMenuRef(null)}
|
||||
/>
|
||||
</div>
|
||||
<div className="video-player-osd-info">
|
||||
<div>
|
||||
<Typography variant="h4" fontWeight={500} mb={2}>
|
||||
{String(itemName)}
|
||||
</Typography>
|
||||
{episodeTitle && (
|
||||
<Typography variant="h6" fontWeight={300} mt={1}>
|
||||
{String(episodeTitle)}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
<div className="video-player-osd-controls">
|
||||
<div className="video-player-osd-controls-timeline">
|
||||
<BubbleSlider />
|
||||
<ProgressDislay />
|
||||
</div>
|
||||
<div className="flex flex-row flex-justify-spaced-between">
|
||||
<div className="video-player-osd-controls-buttons">
|
||||
<PlayPreviousButton />
|
||||
<RewindButton />
|
||||
<PrevChapterButton />
|
||||
|
||||
<PlayPauseButton />
|
||||
|
||||
<NextChapterButton />
|
||||
|
||||
<ForwardButton />
|
||||
<PlayNextButton />
|
||||
|
||||
<Typography variant="subtitle1">
|
||||
{endsAt(itemDuration)}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="video-player-osd-controls-buttons">
|
||||
{/* <motion.div
|
||||
style={{
|
||||
width: "13em",
|
||||
padding: "0.5em 1.5em",
|
||||
paddingLeft: "0.8em",
|
||||
gap: "0.4em",
|
||||
background: "black",
|
||||
borderRadius: "100px",
|
||||
display: "grid",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
gridTemplateColumns: "2em 1fr",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: showVolumeControl ? 1 : 0,
|
||||
}}
|
||||
whileHover={{
|
||||
opacity: 1,
|
||||
}}
|
||||
onMouseLeave={() => setShowVolumeControl(false)}
|
||||
>
|
||||
<Typography textAlign="center">
|
||||
{isPlayerMuted ? 0 : Math.round(playerVolume * 100)}
|
||||
</Typography>
|
||||
<Slider
|
||||
step={0.01}
|
||||
max={1}
|
||||
size="small"
|
||||
value={isPlayerMuted ? 0 : playerVolume}
|
||||
onChange={async (_, newValue) => {
|
||||
if (api && Array.isArray(newValue)) {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue[0],
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue,
|
||||
});
|
||||
}
|
||||
if (newValue === 0)
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_MUTED,
|
||||
payload: true,
|
||||
});
|
||||
else
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_MUTED,
|
||||
payload: true,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</motion.div> */}
|
||||
{/* TODO: Volume menu */}
|
||||
<IconButton
|
||||
onClick={toggleIsPlayerMuted}
|
||||
// onMouseMoveCapture={() => {
|
||||
// setShowVolumeControl(true);
|
||||
// }}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{isPlayerMuted
|
||||
? "volume_off"
|
||||
: volume < 0.4
|
||||
? "volume_down"
|
||||
: "volume_up"}
|
||||
</span>
|
||||
</IconButton>
|
||||
<QueueButton />
|
||||
|
||||
<ChaptersListButton />
|
||||
|
||||
<CaptionsButton />
|
||||
<FullscreenButton />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoPlayerControls;
|
||||
@@ -0,0 +1,138 @@
|
||||
import { MenuItem, Popover, TextField } from "@mui/material";
|
||||
import { toNumber } from "lodash";
|
||||
import React, {
|
||||
type ChangeEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useTransition,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
changeAudioTrack,
|
||||
changeSubtitleTrack,
|
||||
usePlaybackStore,
|
||||
} from "@/utils/store/playback";
|
||||
|
||||
type VideoPlayerSettingsMenuProps = {
|
||||
settingsMenuRef: HTMLButtonElement | null;
|
||||
handleClose: () => void;
|
||||
};
|
||||
|
||||
const VideoPlayerSettingsMenu = ({
|
||||
settingsMenuRef,
|
||||
handleClose,
|
||||
}: VideoPlayerSettingsMenuProps) => {
|
||||
const settingsMenuOpen = useMemo(() => {
|
||||
return Boolean(settingsMenuRef);
|
||||
}, [settingsMenuRef]);
|
||||
|
||||
const api = useApiInContext((state) => state.api);
|
||||
|
||||
const { mediaSource, setIsBuffering } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSource: state.mediaSource,
|
||||
setIsBuffering: state.setIsBuffering,
|
||||
})),
|
||||
);
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
const handleSubtitleChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = useCallback(
|
||||
(e) => {
|
||||
startSubtitleChange(() => {
|
||||
if (mediaSource.subtitle.allTracks) {
|
||||
changeSubtitleTrack(
|
||||
toNumber(e.target.value),
|
||||
mediaSource.subtitle.allTracks,
|
||||
);
|
||||
handleClose();
|
||||
}
|
||||
});
|
||||
},
|
||||
[mediaSource.subtitle?.allTracks],
|
||||
);
|
||||
|
||||
const [audioTackIsChanging, startAudioTrackChange] = useTransition();
|
||||
const handleAudioTrackChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = (e) => {
|
||||
// setPlaying(false);
|
||||
startAudioTrackChange(() => {
|
||||
if (api && mediaSource.audio.allTracks) {
|
||||
changeAudioTrack(toNumber(e.target.value), api);
|
||||
handleClose();
|
||||
setIsBuffering(true);
|
||||
}
|
||||
});
|
||||
|
||||
// setPlaying(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
anchorEl={settingsMenuRef}
|
||||
open={settingsMenuOpen}
|
||||
onClose={handleClose}
|
||||
slotProps={{
|
||||
paper: {
|
||||
style: {
|
||||
maxHeight: "20em",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "1em",
|
||||
width: "24em",
|
||||
padding: "1em",
|
||||
borderRadius: "12px",
|
||||
},
|
||||
className: "glass",
|
||||
},
|
||||
}}
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "right",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "right",
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
select
|
||||
label="Audio"
|
||||
variant="outlined"
|
||||
value={mediaSource.audio?.track}
|
||||
onChange={handleAudioTrackChange}
|
||||
fullWidth
|
||||
disabled={audioTackIsChanging}
|
||||
>
|
||||
{mediaSource.audio?.allTracks?.map((sub) => (
|
||||
<MenuItem key={sub.Index} value={sub.Index}>
|
||||
{sub.DisplayTitle}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<TextField
|
||||
select
|
||||
label="Subtitles"
|
||||
variant="outlined"
|
||||
value={mediaSource.subtitle?.track}
|
||||
onChange={handleSubtitleChange}
|
||||
fullWidth
|
||||
disabled={mediaSource.subtitle?.track === -2 || subtitleIsChanging}
|
||||
>
|
||||
<MenuItem key={-1} value={-1}>
|
||||
No Subtitle
|
||||
</MenuItem>
|
||||
{mediaSource.subtitle?.allTracks?.map((sub) => (
|
||||
<MenuItem key={sub.Index} value={sub.Index}>
|
||||
{sub.DisplayTitle}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoPlayerSettingsMenu;
|
||||
@@ -1,76 +1,74 @@
|
||||
import * as generatedClient from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
BaseItemKind,
|
||||
type CollectionType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import React from "react";
|
||||
|
||||
export const getTypeIcon = (
|
||||
icon:
|
||||
| generatedClient.BaseItemKind
|
||||
| generatedClient.CollectionType
|
||||
| "Home"
|
||||
| "User"
|
||||
| "universal",
|
||||
icon: BaseItemKind | CollectionType | "Home" | "User" | "universal",
|
||||
) => {
|
||||
switch (icon) {
|
||||
case "Home":
|
||||
return <div className="material-symbols-rounded">home</div>;
|
||||
case generatedClient.BaseItemKind.Audio:
|
||||
case BaseItemKind.Audio:
|
||||
return <div className="material-symbols-rounded">mic</div>;
|
||||
case generatedClient.BaseItemKind.AudioBook:
|
||||
case BaseItemKind.AudioBook:
|
||||
return <div className="material-symbols-rounded">speech_to_text</div>;
|
||||
case generatedClient.BaseItemKind.Book:
|
||||
case BaseItemKind.Book:
|
||||
return <div className="material-symbols-rounded">book</div>;
|
||||
case "boxsets":
|
||||
case generatedClient.BaseItemKind.BoxSet:
|
||||
case BaseItemKind.BoxSet:
|
||||
return <div className="material-symbols-rounded">video_library</div>;
|
||||
case "livetv":
|
||||
case generatedClient.BaseItemKind.TvProgram:
|
||||
case generatedClient.BaseItemKind.TvChannel:
|
||||
case generatedClient.BaseItemKind.Program:
|
||||
case generatedClient.BaseItemKind.Recording:
|
||||
case generatedClient.BaseItemKind.LiveTvChannel:
|
||||
case generatedClient.BaseItemKind.LiveTvProgram:
|
||||
case generatedClient.BaseItemKind.ChannelFolderItem:
|
||||
case generatedClient.BaseItemKind.Channel:
|
||||
case BaseItemKind.TvProgram:
|
||||
case BaseItemKind.TvChannel:
|
||||
case BaseItemKind.Program:
|
||||
case BaseItemKind.Recording:
|
||||
case BaseItemKind.LiveTvChannel:
|
||||
case BaseItemKind.LiveTvProgram:
|
||||
case BaseItemKind.ChannelFolderItem:
|
||||
case BaseItemKind.Channel:
|
||||
return (
|
||||
<div className="material-symbols-rounded">settings_input_antenna</div>
|
||||
);
|
||||
case "tvshows":
|
||||
case generatedClient.BaseItemKind.Season:
|
||||
case generatedClient.BaseItemKind.Series:
|
||||
case generatedClient.BaseItemKind.Episode:
|
||||
case BaseItemKind.Season:
|
||||
case BaseItemKind.Series:
|
||||
case BaseItemKind.Episode:
|
||||
return <div className="material-symbols-rounded">tv_gen</div>;
|
||||
case "playlists":
|
||||
case generatedClient.BaseItemKind.Playlist:
|
||||
case generatedClient.BaseItemKind.PlaylistsFolder:
|
||||
case generatedClient.BaseItemKind.ManualPlaylistsFolder:
|
||||
case BaseItemKind.Playlist:
|
||||
case BaseItemKind.PlaylistsFolder:
|
||||
case BaseItemKind.ManualPlaylistsFolder:
|
||||
return <div className="material-symbols-rounded">queue_music</div>;
|
||||
case "movies":
|
||||
case generatedClient.BaseItemKind.Movie:
|
||||
case BaseItemKind.Movie:
|
||||
return <div className="material-symbols-rounded">movie</div>;
|
||||
case generatedClient.BaseItemKind.MusicAlbum:
|
||||
case BaseItemKind.MusicAlbum:
|
||||
return <div className="material-symbols-rounded">album</div>;
|
||||
case generatedClient.BaseItemKind.MusicArtist:
|
||||
case BaseItemKind.MusicArtist:
|
||||
return <div className="material-symbols-rounded">artist</div>;
|
||||
case generatedClient.BaseItemKind.Genre:
|
||||
case generatedClient.BaseItemKind.MusicGenre:
|
||||
case BaseItemKind.Genre:
|
||||
case BaseItemKind.MusicGenre:
|
||||
return <div className="material-symbols-rounded">domino_mask</div>;
|
||||
case "musicvideos":
|
||||
case generatedClient.BaseItemKind.MusicVideo:
|
||||
case BaseItemKind.MusicVideo:
|
||||
return <div className="material-symbols-rounded">music_video</div>;
|
||||
case "User":
|
||||
case generatedClient.BaseItemKind.Person:
|
||||
case BaseItemKind.Person:
|
||||
return <div className="material-symbols-rounded">person</div>;
|
||||
case generatedClient.BaseItemKind.Photo:
|
||||
case BaseItemKind.Photo:
|
||||
return <div className="material-symbols-rounded">image</div>;
|
||||
case "photos":
|
||||
case generatedClient.BaseItemKind.PhotoAlbum:
|
||||
case BaseItemKind.PhotoAlbum:
|
||||
return <div className="material-symbols-rounded">photo_library</div>;
|
||||
case "universal":
|
||||
case generatedClient.BaseItemKind.Studio:
|
||||
case BaseItemKind.Studio:
|
||||
return <div className="material-symbols-rounded">category</div>;
|
||||
case "trailers":
|
||||
case generatedClient.BaseItemKind.Trailer:
|
||||
case BaseItemKind.Trailer:
|
||||
return <div className="material-symbols-rounded">smart_display</div>;
|
||||
case generatedClient.BaseItemKind.Video:
|
||||
case BaseItemKind.Video:
|
||||
return <div className="material-symbols-rounded">theaters</div>;
|
||||
case "music":
|
||||
return <div className="material-symbols-rounded">library_music</div>;
|
||||
|
||||
+410
-600
File diff suppressed because it is too large.
Load diff
+327
-902
File diff suppressed because it is too large.
Load diff
@@ -66,65 +66,4 @@ video {
|
||||
&::cue(i) {
|
||||
text-shadow: 0 2px 10px rgb(0 0 0 / 0.8);
|
||||
}
|
||||
}
|
||||
.video-player {
|
||||
background: black;
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
&-osd {
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: stretch;
|
||||
justify-content: space-between;
|
||||
padding: 1em 2em;
|
||||
background: linear-gradient(to top, rgb(0 0 0 / 0.7) 5vh, transparent 26vh 90vh, rgb(0 0 0 / 0.7));
|
||||
&.hovering {
|
||||
cursor: default;
|
||||
}
|
||||
&-controls {
|
||||
&-progress {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2em;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
margin-bottom: 0.5em;
|
||||
&-text {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: space-between;
|
||||
}
|
||||
&-bubble{
|
||||
width: 14em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transform-origin:bottom center;
|
||||
transform: translate(var(--left, 0), var(--top, 0));
|
||||
position: fixed;
|
||||
|
||||
}
|
||||
}
|
||||
&-buttons {
|
||||
display: flex;
|
||||
gap: 0.4em;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.MuiSlider-valueLabel {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
border-radius: $border-radius-default;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Formats a given ticks value into a human-readable time string.
|
||||
* @param ticks - The ticks value to be formatted, typically in 100-nanosecond intervals.
|
||||
* @returns Formatted time string in the format HH:MM:SS.
|
||||
*/
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
let formatedTime = "";
|
||||
let timeSec = Math.floor(time / 1000);
|
||||
let timeMin = Math.floor(timeSec / 60);
|
||||
timeSec -= timeMin * 60;
|
||||
timeSec = timeSec === 0 ? 0o0 : timeSec;
|
||||
const timeHr = Math.floor(timeMin / 60);
|
||||
timeMin -= timeHr * 60;
|
||||
formatedTime = `${timeHr.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeMin.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeSec.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}`;
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
export default ticksDisplay;
|
||||
+597
-141
@@ -7,8 +7,12 @@ import type {
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { create } from "zustand";
|
||||
import { immer } from "zustand/middleware/immer";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { createWithEqualityFn } from "zustand/traditional";
|
||||
import { secToTicks, ticksToSec } from "../date/time";
|
||||
import getSubtitle from "../methods/getSubtitles";
|
||||
import playbackProfile from "../playback-profiles";
|
||||
import type audioPlaybackInfo from "../types/audioPlaybackInfo";
|
||||
@@ -16,9 +20,7 @@ import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
||||
import { generateAudioStreamUrl, playAudio } from "./audioPlayback";
|
||||
import useQueue, { setQueue } from "./queue";
|
||||
|
||||
type PlaybackStore = {
|
||||
itemName: string | React.Component | undefined | null;
|
||||
episodeTitle: string | React.Component;
|
||||
type PlaybackStoreState = {
|
||||
mediaSource: {
|
||||
videoTrack: number;
|
||||
audioTrack: number;
|
||||
@@ -28,123 +30,549 @@ type PlaybackStore = {
|
||||
audio: audioPlaybackInfo;
|
||||
};
|
||||
playbackStream: string;
|
||||
userId: string;
|
||||
startPosition: number;
|
||||
itemDuration: number;
|
||||
item: BaseItemDto | null;
|
||||
playsessionId: string | undefined | null;
|
||||
intro: MediaSegmentDtoQueryResult | undefined;
|
||||
volume: number | undefined;
|
||||
metadata: {
|
||||
itemName: string;
|
||||
episodeTitle?: string;
|
||||
isEpisode: boolean;
|
||||
/**
|
||||
* Duration of the item in C# ticks
|
||||
* This is used to calculate the progress bar and the total duration of the item
|
||||
*/
|
||||
itemDuration: number;
|
||||
item: BaseItemDto;
|
||||
mediaSegments?: MediaSegmentDtoQueryResult;
|
||||
userDataLastPlayedPositionTicks?: number;
|
||||
};
|
||||
playerState: {
|
||||
/**
|
||||
* Persistent volume level between player instances
|
||||
*/
|
||||
volume: number;
|
||||
/**
|
||||
* Prop for ReactPlayer to mute and unmute audio volume regardless of the volume value
|
||||
*/
|
||||
isPlayerMuted: boolean;
|
||||
isPlayerPlaying: boolean;
|
||||
/**
|
||||
* Used to check if ReactPlayer component has finished initial fetch of playbackStream
|
||||
* true -> Player is ready for playback
|
||||
* false -> Player is not ready for playback/is still fetching data/possible error while fetching
|
||||
*/
|
||||
isPlayerReady: boolean;
|
||||
isBuffering: boolean;
|
||||
/**
|
||||
* Current playback time in C# ticks
|
||||
* This is used to update the playback time in the UI
|
||||
* Initially should be set to UserData.PlaybackPositionTicks in seconds
|
||||
* Source: ReactPlayer's onProgress event
|
||||
* */
|
||||
currentTime: number;
|
||||
/**
|
||||
* Used to toggle the fullscreen state of the player
|
||||
* This is used to toggle the fullscreen state of the player
|
||||
* This should be set to true when the user clicks on the fullscreen button
|
||||
*/
|
||||
isPlayerFullscreen: boolean;
|
||||
/**
|
||||
* Used to see if user is seeking/scrubbing progress bar
|
||||
* Used to temporarily switch to seek progress for the progress bar
|
||||
*/
|
||||
isUserSeeking: boolean;
|
||||
/**
|
||||
* Seek value
|
||||
* This value should be in C# ticks
|
||||
*/
|
||||
seekValue: number;
|
||||
/**
|
||||
* Used to display controls/see if user is hovering the media player
|
||||
*/
|
||||
isUserHovering: boolean;
|
||||
/**
|
||||
* Used to show the buffering spinner in the UI
|
||||
* This should be set to true when the player is buffering
|
||||
*/
|
||||
isLoading: boolean;
|
||||
};
|
||||
/**
|
||||
* Index of the next segment to be played
|
||||
*/
|
||||
nextSegmentIndex: number;
|
||||
/**
|
||||
* Id of the active segment
|
||||
* Set if null if no segment is active
|
||||
*/
|
||||
activeSegmentId: string | null;
|
||||
/**
|
||||
* User id of the user who is currently playing the item
|
||||
*/
|
||||
userId: string;
|
||||
/**
|
||||
* Volume change indicator
|
||||
* This is used to show the volume change indicator in the UI
|
||||
*/
|
||||
isVolumeInidcatorVisible: boolean;
|
||||
volumeIndicatorVisibleTimeoutId: NodeJS.Timeout | null;
|
||||
};
|
||||
|
||||
export const usePlaybackStore = createWithEqualityFn<PlaybackStore>(
|
||||
() => ({
|
||||
itemName: undefined!,
|
||||
episodeTitle: "",
|
||||
type PlaybackStoreActions = {
|
||||
// Player state related actions
|
||||
/**
|
||||
* Set the volume of the player
|
||||
* This is used to set the volume of the player
|
||||
* This should be set to a value between 0 and 1
|
||||
*/
|
||||
setVolume: (volume: number) => void;
|
||||
/**
|
||||
* Increase the volume of the player by a step
|
||||
* This is used to increase the volume of the player by a step
|
||||
* This should be set to a value between 0 and 1
|
||||
*/
|
||||
increaseVolumeByStep: (step: number) => void;
|
||||
/**
|
||||
* Decrease the volume of the player by a step
|
||||
* This is used to decrease the volume of the player by a step
|
||||
* This should be set to a value between 0 and 1
|
||||
*/
|
||||
decreaseVolumeByStep: (step: number) => void;
|
||||
/**
|
||||
* Toggle the player state between playing and paused
|
||||
* This is used to toggle the player state
|
||||
*/
|
||||
toggleIsPlaying: () => void;
|
||||
/**
|
||||
* Set the player state to playing
|
||||
*/
|
||||
setIsPlaying: (isPlaying: boolean) => void;
|
||||
/**
|
||||
* Set the player state to buffering
|
||||
* This is used to show the buffering spinner in the UI
|
||||
* This should be set to true when the player is buffering
|
||||
*/
|
||||
setIsBuffering: (isBuffering: boolean) => void;
|
||||
/**
|
||||
* Set the current time of the player
|
||||
*/
|
||||
setCurrentTime: (currentTime: number) => void;
|
||||
/**
|
||||
* Set the player state to ready
|
||||
* This is used to check if the player is ready for playback
|
||||
* This should be set to true when the player has finished fetching the playback stream
|
||||
*/
|
||||
setPlayerReady: (isPlayerReady: boolean) => void;
|
||||
/**
|
||||
* Toggle the player state to fullscreen
|
||||
* This is used to toggle the fullscreen state of the player
|
||||
* This should be set to true when the user clicks on the fullscreen button
|
||||
*/
|
||||
toggleIsPlayerFullscreen: () => void;
|
||||
/**
|
||||
* Set the user hover state
|
||||
* This is used to show/hide the player controls
|
||||
* This should be set to true when the user hovers over the player
|
||||
* This should be set to false when the user stops hovering over the player
|
||||
*/
|
||||
setIsUserHovering: (isUserHovering: boolean) => void;
|
||||
/**
|
||||
* Set the user seeking state
|
||||
* This is used to temporarily switch to seek progress for the progress bar
|
||||
* This should be set to true when the user is seeking/scrubbing the progress bar
|
||||
*/
|
||||
setIsUserSeeking: (isUserSeeking: boolean) => void;
|
||||
/**
|
||||
* Set the seek value
|
||||
* This is used to update the seek value in the UI
|
||||
* This should be set to the value of the progress bar when the user is seeking/scrubbing
|
||||
* This value should be in C# ticks
|
||||
*/
|
||||
setSeekValue: (seekValue: number) => void;
|
||||
/**
|
||||
* Toggle the player muted state
|
||||
* This is used to toggle the player muted state
|
||||
*/
|
||||
toggleIsPlayerMuted: () => void;
|
||||
/**
|
||||
* Set the loading state of the player
|
||||
* This is used to show/hide the loading spinner in the UI
|
||||
* This should be set to true when the player is loading
|
||||
* This should be set to false when the player has finished loading
|
||||
*/
|
||||
setIsLoading: (isLoading: boolean) => void;
|
||||
setPlayerState: (playerState: PlaybackStoreState["playerState"]) => void;
|
||||
|
||||
// Playback information related actions
|
||||
setMetadata: (
|
||||
itemName: string,
|
||||
episodeTitle: string,
|
||||
isEpisode: boolean,
|
||||
itemDuration: number,
|
||||
item: BaseItemDto,
|
||||
mediaSegments?: MediaSegmentDtoQueryResult,
|
||||
userDataLastPlayedPositionTicks?: number,
|
||||
) => void;
|
||||
setMediaSource: (
|
||||
videoTrack: number,
|
||||
audioTrack: number,
|
||||
container: string,
|
||||
id: string | undefined,
|
||||
subtitle: subtitlePlaybackInfo,
|
||||
audio: audioPlaybackInfo,
|
||||
) => void;
|
||||
setPlaybackStream: (playbackStream: string) => void;
|
||||
setPlaysessionId: (playsessionId: string | undefined | null) => void;
|
||||
setUserId: (userId: string) => void;
|
||||
setActiveSegment: (segmentIndex: number) => void;
|
||||
clearActiveSegment: () => void;
|
||||
|
||||
/**
|
||||
* Trigger volume change indicator
|
||||
* This is used to show the volume change indicator in the UI
|
||||
*/
|
||||
tiggerVolumeIndicator: () => void;
|
||||
|
||||
// ReactPlayer related actions
|
||||
_playerActions: {
|
||||
seekTo: (seconds: number) => void;
|
||||
getCurrentTime: () => number;
|
||||
};
|
||||
registerPlayerActions: (
|
||||
actions: PlaybackStoreActions["_playerActions"],
|
||||
) => void;
|
||||
seekTo: (seconds: number) => void;
|
||||
seekForward: (seconds: number) => void;
|
||||
seekBackward: (seconds: number) => void;
|
||||
getCurrentTime: () => number;
|
||||
seekToNextChapter: () => void;
|
||||
seekToPrevChapter: () => void;
|
||||
handleStartSeek: (ticks: number) => void;
|
||||
handleStopSeek: (ticks: number) => void;
|
||||
/**
|
||||
* Skip current media segment
|
||||
*/
|
||||
skipSegment: () => void;
|
||||
};
|
||||
|
||||
export const usePlaybackStore = create<
|
||||
PlaybackStoreState & PlaybackStoreActions
|
||||
>()(
|
||||
immer((set, get) => ({
|
||||
mediaSource: {
|
||||
videoTrack: 0,
|
||||
audioTrack: 0,
|
||||
container: "",
|
||||
id: undefined,
|
||||
subtitle: {
|
||||
enable: false,
|
||||
track: undefined!,
|
||||
format: "ass",
|
||||
allTracks: undefined,
|
||||
url: undefined,
|
||||
},
|
||||
audio: {
|
||||
track: undefined!,
|
||||
allTracks: undefined,
|
||||
videoTrack: undefined!,
|
||||
audioTrack: undefined!,
|
||||
container: undefined!,
|
||||
id: undefined!,
|
||||
subtitle: undefined!,
|
||||
audio: undefined!,
|
||||
},
|
||||
playbackStream: undefined!,
|
||||
playsessionId: undefined!,
|
||||
metadata: {
|
||||
itemName: undefined!,
|
||||
episodeTitle: undefined,
|
||||
isEpisode: false,
|
||||
itemDuration: undefined!,
|
||||
item: undefined!,
|
||||
mediaSegments: undefined,
|
||||
userDataLastPlayedPositionTicks: 0,
|
||||
},
|
||||
playerState: {
|
||||
volume: 1,
|
||||
isPlayerMuted: false,
|
||||
isPlayerPlaying: true,
|
||||
isPlayerReady: false,
|
||||
isPlayerFullscreen: false,
|
||||
isUserHovering: false,
|
||||
isBuffering: true,
|
||||
currentTime: undefined!,
|
||||
isUserSeeking: false,
|
||||
seekValue: 0,
|
||||
isLoading: true,
|
||||
},
|
||||
userId: undefined!,
|
||||
// -- MediaSegment skip feature --
|
||||
nextSegmentIndex: 0,
|
||||
activeSegmentId: null,
|
||||
|
||||
// -- Volume change indicator --
|
||||
isVolumeInidcatorVisible: false,
|
||||
volumeIndicatorVisibleTimeoutId: null,
|
||||
|
||||
// -- Player state related actions --
|
||||
setVolume: (volume) => {
|
||||
if (volume < 0 || volume > 1) {
|
||||
console.warn("Volume must be between 0 and 1");
|
||||
}
|
||||
set((state) => {
|
||||
state.playerState.volume = volume;
|
||||
state.playerState.isPlayerMuted = volume === 0; // Mute if volume is 0
|
||||
});
|
||||
get().tiggerVolumeIndicator(); // Trigger volume change indicator
|
||||
},
|
||||
increaseVolumeByStep: (step) => {
|
||||
set((state) => {
|
||||
state.playerState.volume = Math.min(
|
||||
1,
|
||||
Math.max(0, state.playerState.volume + step),
|
||||
);
|
||||
});
|
||||
get().tiggerVolumeIndicator(); // Trigger volume change indicator
|
||||
},
|
||||
decreaseVolumeByStep: (step) => {
|
||||
set((state) => {
|
||||
state.playerState.volume = Math.min(
|
||||
1,
|
||||
Math.max(0, state.playerState.volume - step),
|
||||
);
|
||||
});
|
||||
get().tiggerVolumeIndicator(); // Trigger volume change indicator
|
||||
},
|
||||
toggleIsPlaying: () => {
|
||||
set((state) => {
|
||||
state.playerState.isPlayerPlaying = !state.playerState.isPlayerPlaying;
|
||||
});
|
||||
},
|
||||
setIsPlaying: (isPlaying) =>
|
||||
set((state) => {
|
||||
state.playerState.isPlayerPlaying = isPlaying;
|
||||
}),
|
||||
setIsBuffering: (isBuffering) =>
|
||||
set((state) => {
|
||||
state.playerState.isBuffering = isBuffering;
|
||||
}),
|
||||
setCurrentTime: (currentTime) =>
|
||||
set((state) => {
|
||||
state.playerState.currentTime = currentTime;
|
||||
}),
|
||||
setPlayerReady: (isPlayerReady) =>
|
||||
set((state) => {
|
||||
state.playerState.isPlayerReady = isPlayerReady;
|
||||
}),
|
||||
setMetadata: (
|
||||
itemName: string,
|
||||
episodeTitle: string,
|
||||
isEpisode: boolean,
|
||||
itemDuration: number,
|
||||
item: BaseItemDto,
|
||||
mediaSegments?: MediaSegmentDtoQueryResult,
|
||||
) =>
|
||||
set((state) => {
|
||||
state.metadata.itemName = itemName;
|
||||
state.metadata.episodeTitle = episodeTitle;
|
||||
state.metadata.isEpisode = isEpisode;
|
||||
state.metadata.itemDuration = itemDuration;
|
||||
state.metadata.item = item;
|
||||
state.metadata.mediaSegments = mediaSegments;
|
||||
}),
|
||||
setMediaSource: (
|
||||
videoTrack: number,
|
||||
audioTrack: number,
|
||||
container: string,
|
||||
id: string | undefined,
|
||||
subtitle: subtitlePlaybackInfo,
|
||||
audio: audioPlaybackInfo,
|
||||
) =>
|
||||
set((state) => {
|
||||
state.mediaSource.videoTrack = videoTrack;
|
||||
state.mediaSource.audioTrack = audioTrack;
|
||||
state.mediaSource.container = container;
|
||||
state.mediaSource.id = id;
|
||||
state.mediaSource.subtitle = subtitle;
|
||||
state.mediaSource.audio = audio;
|
||||
}),
|
||||
setPlaybackStream: (playbackStream: string) =>
|
||||
set((state) => {
|
||||
state.playbackStream = playbackStream;
|
||||
}),
|
||||
setPlaysessionId: (playsessionId) =>
|
||||
set((state) => {
|
||||
state.playsessionId = playsessionId;
|
||||
}),
|
||||
toggleIsPlayerFullscreen: async () => {
|
||||
await appWindow
|
||||
.getCurrent()
|
||||
.setFullscreen(!get().playerState.isPlayerFullscreen);
|
||||
set((state) => {
|
||||
state.playerState.isPlayerFullscreen =
|
||||
!state.playerState.isPlayerFullscreen;
|
||||
});
|
||||
},
|
||||
setIsUserHovering: (isUserHovering) =>
|
||||
set((state) => {
|
||||
state.playerState.isUserHovering = isUserHovering;
|
||||
}),
|
||||
setIsUserSeeking: (isUserSeeking) =>
|
||||
set((state) => {
|
||||
state.playerState.isUserSeeking = isUserSeeking;
|
||||
}),
|
||||
setSeekValue: (seekValue) =>
|
||||
set((state) => {
|
||||
state.playerState.seekValue = seekValue;
|
||||
}),
|
||||
toggleIsPlayerMuted: () =>
|
||||
set((state) => {
|
||||
state.playerState.isPlayerMuted = !state.playerState.isPlayerMuted;
|
||||
}),
|
||||
setIsLoading: (isLoading) =>
|
||||
set((state) => {
|
||||
state.playerState.isLoading = isLoading;
|
||||
}),
|
||||
setPlayerState: (playerState) =>
|
||||
set((state) => ({
|
||||
...state,
|
||||
playerState: {
|
||||
...state.playerState,
|
||||
...playerState,
|
||||
},
|
||||
})),
|
||||
setUserId: (userId) =>
|
||||
set(() => ({
|
||||
userId: userId,
|
||||
})),
|
||||
setActiveSegment: (segmentIndex) => {
|
||||
const segment = get().metadata.mediaSegments?.Items?.[segmentIndex];
|
||||
set((state) => {
|
||||
state.nextSegmentIndex = segmentIndex + 1;
|
||||
state.activeSegmentId = segment?.Id ?? null;
|
||||
});
|
||||
},
|
||||
clearActiveSegment: () => {
|
||||
set((state) => {
|
||||
state.activeSegmentId = null;
|
||||
});
|
||||
},
|
||||
|
||||
// -- Volume change indicator Action --
|
||||
tiggerVolumeIndicator: () => {
|
||||
const timeoutId = get().volumeIndicatorVisibleTimeoutId;
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId); // Volume indicator is already visible
|
||||
}
|
||||
set((state) => {
|
||||
state.isVolumeInidcatorVisible = true;
|
||||
state.volumeIndicatorVisibleTimeoutId = setTimeout(() => {
|
||||
set((state) => {
|
||||
state.isVolumeInidcatorVisible = false;
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
|
||||
// -- ReactPlayer related actions --
|
||||
_playerActions: {
|
||||
seekTo: (seconds: number) =>
|
||||
console.warn(
|
||||
"ReactPlayer has not yet initialized. Please wait until the player is ready to seek.",
|
||||
),
|
||||
getCurrentTime: () => {
|
||||
console.warn(
|
||||
"ReactPlayer has not yet initialized. Please wait until the player is ready to get current time.",
|
||||
);
|
||||
return 0;
|
||||
},
|
||||
},
|
||||
enableSubtitle: true,
|
||||
playbackStream: "",
|
||||
userId: "",
|
||||
startPosition: 0,
|
||||
itemDuration: 0,
|
||||
item: null,
|
||||
playsessionId: "",
|
||||
intro: undefined,
|
||||
volume: 1,
|
||||
}),
|
||||
shallow,
|
||||
registerPlayerActions: (actions) =>
|
||||
set({
|
||||
_playerActions: actions,
|
||||
}),
|
||||
seekTo: (seconds: number) => {
|
||||
const playerActions = get()._playerActions;
|
||||
playerActions.seekTo(seconds);
|
||||
},
|
||||
seekForward: (seconds: number) => {
|
||||
const playerActions = get()._playerActions;
|
||||
const currentTime = playerActions.getCurrentTime();
|
||||
playerActions.seekTo(currentTime + seconds);
|
||||
},
|
||||
seekBackward: (seconds: number) => {
|
||||
const playerActions = get()._playerActions;
|
||||
const currentTime = playerActions.getCurrentTime();
|
||||
playerActions.seekTo(Math.max(0, currentTime - seconds));
|
||||
},
|
||||
getCurrentTime: () => {
|
||||
const playerActions = get()._playerActions;
|
||||
return playerActions.getCurrentTime();
|
||||
},
|
||||
seekToNextChapter: () => {
|
||||
const playerActions = get()._playerActions;
|
||||
const next = get().metadata.item?.Chapters?.filter((chapter) => {
|
||||
if (
|
||||
(chapter.StartPositionTicks ?? 0) > playerActions.getCurrentTime()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
})[0];
|
||||
playerActions.seekTo(ticksToSec(next?.StartPositionTicks ?? 0));
|
||||
},
|
||||
seekToPrevChapter: () => {
|
||||
const playerActions = get()._playerActions;
|
||||
const chapters = get().metadata.item.Chapters?.filter((chapter) => {
|
||||
if (
|
||||
(chapter.StartPositionTicks ?? 0) <=
|
||||
secToTicks(playerActions.getCurrentTime())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!chapters?.length) {
|
||||
playerActions.seekTo(0);
|
||||
}
|
||||
if (chapters?.length === 1) {
|
||||
playerActions.seekTo(ticksToSec(chapters[0].StartPositionTicks ?? 0));
|
||||
} else if ((chapters?.length ?? 0) > 1) {
|
||||
playerActions.seekTo(
|
||||
ticksToSec(chapters?.[chapters.length - 2].StartPositionTicks ?? 0),
|
||||
);
|
||||
}
|
||||
},
|
||||
skipSegment: () => {
|
||||
const activeSegmentId = get().activeSegmentId;
|
||||
const activeSegment = get().metadata.mediaSegments?.Items?.find(
|
||||
(s) => s.Id === activeSegmentId,
|
||||
);
|
||||
if (!activeSegment) {
|
||||
console.warn("No segment to skip");
|
||||
return;
|
||||
}
|
||||
get()._playerActions.seekTo(activeSegment.EndTicks ?? 0);
|
||||
},
|
||||
handleStartSeek: (ticks) => {
|
||||
set((state) => {
|
||||
state.playerState.isUserSeeking = true;
|
||||
state.playerState.seekValue = ticks;
|
||||
});
|
||||
},
|
||||
handleStopSeek: (ticks) => {
|
||||
const playerActions = get()._playerActions;
|
||||
playerActions.seekTo(ticksToSec(ticks));
|
||||
// Update current time to the new seek value
|
||||
set((state) => {
|
||||
state.playerState.isUserSeeking = false;
|
||||
state.playerState.currentTime = ticks;
|
||||
});
|
||||
},
|
||||
})),
|
||||
);
|
||||
|
||||
export const playItem = (
|
||||
itemName: string | React.Component | undefined | null,
|
||||
episodeTitle: string,
|
||||
videoTrack: number,
|
||||
audioTrack: number,
|
||||
container: string,
|
||||
playbackStream: string,
|
||||
userId: string,
|
||||
startPosition: number | undefined | null,
|
||||
itemDuration: number | undefined | null,
|
||||
item: BaseItemDto,
|
||||
queue: BaseItemDto[] | undefined | null,
|
||||
queueItemIndex: number,
|
||||
mediaSourceId: string | undefined | null,
|
||||
playsessionId: string | undefined | null,
|
||||
subtitle: subtitlePlaybackInfo | undefined,
|
||||
intro: MediaSegmentDtoQueryResult | undefined,
|
||||
audio: audioPlaybackInfo,
|
||||
volume: number | undefined = 1,
|
||||
) => {
|
||||
console.log({
|
||||
itemName,
|
||||
episodeTitle,
|
||||
mediaSource: {
|
||||
videoTrack,
|
||||
audioTrack,
|
||||
container,
|
||||
id: mediaSourceId,
|
||||
subtitle,
|
||||
audio,
|
||||
},
|
||||
playbackStream,
|
||||
userId,
|
||||
startPosition,
|
||||
itemDuration,
|
||||
item,
|
||||
playsessionId,
|
||||
intro,
|
||||
volume,
|
||||
export const playItem = (args: {
|
||||
mediaSource: PlaybackStoreState["mediaSource"];
|
||||
playbackStream: PlaybackStoreState["playbackStream"];
|
||||
playsessionId: PlaybackStoreState["playsessionId"];
|
||||
metadata: PlaybackStoreState["metadata"];
|
||||
userDataPlayedPositionTicks: number;
|
||||
userId: string;
|
||||
queueItems: BaseItemDto[];
|
||||
queueItemIndex: number;
|
||||
}) => {
|
||||
usePlaybackStore.setState((state) => {
|
||||
state.mediaSource = args.mediaSource;
|
||||
state.playbackStream = args.playbackStream;
|
||||
state.playsessionId = args.playsessionId;
|
||||
state.metadata = args.metadata;
|
||||
state.playerState.currentTime = args.userDataPlayedPositionTicks;
|
||||
state.userId = args.userId;
|
||||
});
|
||||
|
||||
if (!queue) {
|
||||
throw new Error("No queue found");
|
||||
}
|
||||
|
||||
if (!mediaSourceId) {
|
||||
throw new Error("No media source id found");
|
||||
}
|
||||
|
||||
if (!subtitle) {
|
||||
throw new Error("No subtitle config found");
|
||||
}
|
||||
|
||||
usePlaybackStore.setState({
|
||||
itemName,
|
||||
episodeTitle,
|
||||
mediaSource: {
|
||||
videoTrack,
|
||||
audioTrack,
|
||||
container,
|
||||
id: mediaSourceId,
|
||||
subtitle,
|
||||
audio,
|
||||
},
|
||||
playbackStream,
|
||||
userId,
|
||||
startPosition: startPosition ?? 0,
|
||||
itemDuration: itemDuration ?? 0,
|
||||
item,
|
||||
playsessionId,
|
||||
intro,
|
||||
volume,
|
||||
});
|
||||
setQueue(queue, queueItemIndex);
|
||||
setQueue(args.queueItems, args.queueItemIndex ?? 0);
|
||||
};
|
||||
|
||||
export const playItemFromQueue = async (
|
||||
@@ -197,6 +625,18 @@ export const playItemFromQueue = async (
|
||||
console.error("No media source id found");
|
||||
return;
|
||||
}
|
||||
if (!item) {
|
||||
throw new Error("Item is undefined in playItemFromQueue");
|
||||
}
|
||||
if (!item.Name) {
|
||||
throw new Error("Item name is undefined in playItemFromQueue");
|
||||
}
|
||||
if (!item.RunTimeTicks) {
|
||||
throw new Error("Item run time ticks is undefined in playItemFromQueue");
|
||||
}
|
||||
if (!item.Id) {
|
||||
throw new Error("Item id is undefined in playItemFromQueue");
|
||||
}
|
||||
|
||||
const mediaSource = (
|
||||
await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
@@ -217,9 +657,13 @@ export const playItemFromQueue = async (
|
||||
},
|
||||
})
|
||||
).data;
|
||||
if (!mediaSource.MediaSources?.[0]?.Id) {
|
||||
throw new Error("Media source is undefined in playItemFromQueue");
|
||||
}
|
||||
|
||||
let itemName = item.Name;
|
||||
let episodeTitle = "";
|
||||
if (item.SeriesId) {
|
||||
if (item.SeriesId && item.SeriesName) {
|
||||
itemName = item.SeriesName;
|
||||
episodeTitle = `S${item.ParentIndexNumber ?? 0}:E${
|
||||
item.IndexNumber ?? 0
|
||||
@@ -264,7 +708,7 @@ export const playItemFromQueue = async (
|
||||
(value) => value.Type === "Video",
|
||||
);
|
||||
|
||||
const introInfo = (
|
||||
const mediaSegments = (
|
||||
await getMediaSegmentsApi(api).getItemSegments({
|
||||
itemId: item.Id ?? "",
|
||||
})
|
||||
@@ -280,25 +724,40 @@ export const playItemFromQueue = async (
|
||||
},
|
||||
});
|
||||
|
||||
playItem(
|
||||
itemName,
|
||||
episodeTitle,
|
||||
videoTrack?.[0].Index ?? 0,
|
||||
mediaSource.MediaSources?.[0].DefaultAudioStreamIndex ?? 0,
|
||||
mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
||||
playbackUrl,
|
||||
playItem({
|
||||
metadata: {
|
||||
itemName,
|
||||
episodeTitle: episodeTitle,
|
||||
isEpisode: !!item.SeriesId,
|
||||
itemDuration: item.RunTimeTicks,
|
||||
item: item,
|
||||
mediaSegments: mediaSegments,
|
||||
userDataLastPlayedPositionTicks:
|
||||
item.UserData?.PlaybackPositionTicks ?? 0,
|
||||
},
|
||||
mediaSource: {
|
||||
videoTrack: videoTrack?.[0]?.Index ?? 0,
|
||||
audioTrack: audio.track,
|
||||
container: mediaSource.MediaSources?.[0].Container ?? "",
|
||||
id: mediaSource.MediaSources?.[0]?.Id,
|
||||
subtitle: {
|
||||
url: subtitle?.url,
|
||||
track: subtitle?.track ?? -1,
|
||||
format: subtitle?.format ?? "nosub",
|
||||
allTracks: mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||
(value) => value.Type === "Subtitle",
|
||||
),
|
||||
enable: subtitle?.enable ?? false,
|
||||
},
|
||||
audio: audio,
|
||||
},
|
||||
playbackStream: playbackUrl,
|
||||
playsessionId: mediaSource.PlaySessionId,
|
||||
userDataPlayedPositionTicks: item.UserData?.PlaybackPositionTicks ?? 0,
|
||||
userId,
|
||||
item.UserData?.PlaybackPositionTicks,
|
||||
item.RunTimeTicks,
|
||||
item,
|
||||
queueItems,
|
||||
requestedItemIndex,
|
||||
mediaSource.MediaSources?.[0]?.Id,
|
||||
mediaSource.PlaySessionId,
|
||||
subtitle,
|
||||
introInfo,
|
||||
audio,
|
||||
);
|
||||
queueItems: queueItems,
|
||||
queueItemIndex: requestedItemIndex,
|
||||
});
|
||||
}
|
||||
|
||||
return "playing"; // Return any value to end mutation pending status
|
||||
@@ -355,26 +814,23 @@ export const toggleSubtitleTrack = () => {
|
||||
* @param api api instance
|
||||
* @param startPosition position of videoPlayer during audio track change (this should be in ticks)
|
||||
*/
|
||||
export const changeAudioTrack = async (
|
||||
trackIndex: number,
|
||||
api: Api,
|
||||
startPosition: number,
|
||||
) => {
|
||||
export const changeAudioTrack = async (trackIndex: number, api: Api) => {
|
||||
const prevState = usePlaybackStore.getState();
|
||||
if (!prevState.item?.Id) {
|
||||
|
||||
if (!prevState.metadata.item?.Id) {
|
||||
throw new Error("item is undefined in changeAudioTrack");
|
||||
}
|
||||
if (!prevState.item.MediaSources?.[0].Id) {
|
||||
if (!prevState.metadata.item.MediaSources?.[0].Id) {
|
||||
throw new Error("Media source id is undefined in changeAudioTrack");
|
||||
}
|
||||
const mediaSource = (
|
||||
await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: trackIndex,
|
||||
subtitleStreamIndex: prevState.mediaSource.subtitle.track,
|
||||
itemId: prevState.item.Id,
|
||||
startTimeTicks: prevState.item.UserData?.PlaybackPositionTicks,
|
||||
itemId: prevState.metadata.item.Id,
|
||||
startTimeTicks: prevState.metadata.item.UserData?.PlaybackPositionTicks,
|
||||
userId: prevState.userId,
|
||||
mediaSourceId: prevState.item.MediaSources?.[0].Id,
|
||||
mediaSourceId: prevState.metadata.item.MediaSources?.[0].Id,
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
@@ -404,7 +860,7 @@ export const changeAudioTrack = async (
|
||||
}
|
||||
|
||||
prevState.playbackStream = playbackUrl;
|
||||
prevState.startPosition = startPosition;
|
||||
// prevState.item = startPosition;
|
||||
prevState.playsessionId = mediaSource.PlaySessionId;
|
||||
|
||||
usePlaybackStore.setState(prevState);
|
||||
|
||||
+6
-3
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import svgr from "vite-plugin-svgr";
|
||||
import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
|
||||
import { tanstackRouter } from '@tanstack/router-vite-plugin'
|
||||
import MillionLint from "@million/lint";
|
||||
import path from "path";
|
||||
|
||||
@@ -20,7 +20,11 @@ const plugins = [react({
|
||||
}],
|
||||
],
|
||||
}
|
||||
}), svgr(), TanStackRouterVite()];
|
||||
}), svgr(), tanstackRouter(), MillionLint.vite({
|
||||
// Enable Million's linting capabilities
|
||||
enabled: true,
|
||||
|
||||
})];
|
||||
export default defineConfig({
|
||||
plugins: plugins,
|
||||
css: {
|
||||
@@ -30,7 +34,6 @@ export default defineConfig({
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
additionalData: '@use "/src/styles/variables.scss" as *;',
|
||||
api:"modern-compiler"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user