Compare commits
5
Commits
df847becc8
...
2790d92a60
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2790d92a60 | ||
|
|
3d61740f5a | ||
|
|
20b8fcc1c1 | ||
|
|
821332508f | ||
|
|
8e6392a84c |
No files matched your search
@@ -0,0 +1,82 @@
|
||||
# Vérifications à chaque push / pull request, et release Gitea avec le paquet FreeStore
|
||||
# sur un tag « vX.Y.Z » (qui doit correspondre à « version » dans manifest.json).
|
||||
# Le téléversement sur la console FreeFactory reste manuel (pas d'API connue).
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Vérifications et paquet
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Dépendances (Qt 5, qmllint, libfbxqml)
|
||||
run: |
|
||||
SUDO=$(command -v sudo || true)
|
||||
$SUDO apt-get update -qq
|
||||
DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y -qq --no-install-recommends \
|
||||
python3 git ca-certificates qmlscene qtdeclarative5-dev-tools \
|
||||
qml-module-qtquick2 qml-module-qtquick-window2 qml-module-qtmultimedia
|
||||
git clone --depth 1 https://github.com/fbx/libfbxqml.git ../libfbxqml
|
||||
|
||||
- name: Manifest, syntaxe QML/JS et paquet FreeStore
|
||||
run: python3 tools/package.py
|
||||
|
||||
- name: Chargement en HTTP, comme sur la box
|
||||
run: tools/check-load.sh
|
||||
|
||||
- name: Paquet en artefact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: freestore-package
|
||||
path: dist/*.tar.gz
|
||||
|
||||
release:
|
||||
name: Release Gitea
|
||||
needs: check
|
||||
if: startsWith(gitea.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Dépendances
|
||||
run: |
|
||||
SUDO=$(command -v sudo || true)
|
||||
$SUDO apt-get update -qq
|
||||
DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y -qq --no-install-recommends \
|
||||
python3 curl ca-certificates
|
||||
|
||||
- name: Le tag correspond à la version du manifest
|
||||
env:
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
VERSION=$(python3 -c "import json; print(json.load(open('manifest.json'))['version'])")
|
||||
if [ "$TAG" != "v$VERSION" ]; then
|
||||
echo "Le tag $TAG ne correspond pas à la version du manifest (v$VERSION)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: freestore-package
|
||||
path: dist
|
||||
|
||||
- name: Créer la release et joindre le paquet
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
FILE=$(ls dist/*.tar.gz)
|
||||
BODY=$(python3 -c "import json,sys; print(json.dumps({'tag_name': sys.argv[1], 'name': sys.argv[1], 'body': 'Paquet FreeStore à téléverser sur la console FreeFactory (http://factory.free.fr).'}))" "$TAG")
|
||||
ID=$(curl -sSf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
"$API/releases" -d "$BODY" | python3 -c "import json,sys; print(json.load(sys.stdin)['id'])")
|
||||
curl -sSf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$FILE" \
|
||||
"$API/releases/$ID/assets?name=$(basename "$FILE")" > /dev/null
|
||||
echo "Release $TAG créée avec $(basename "$FILE")."
|
||||
@@ -73,3 +73,10 @@ Thumbs.db
|
||||
|
||||
# Log de tools/deploy.py
|
||||
deploy.log
|
||||
|
||||
# Paquets FreeStore (tools/package.py)
|
||||
dist/
|
||||
|
||||
# Environnement Python local (Rider)
|
||||
.venv/
|
||||
.idea/**
|
||||
@@ -17,9 +17,14 @@ There is no build system or test suite.
|
||||
- `QT_QPA_PLATFORM=offscreen tools/run-local.sh` — headless run, useful to catch QML warnings.
|
||||
- HTTPS on the PC works with the system `qmlscene` (Qt 5.15 + OpenSSL 3). PyQt5 wheels from pip bundle a Qt built for OpenSSL 1.x and cannot do TLS here.
|
||||
- Lint: `qmllint Jellyfin.qml Components/*.qml Core/*.qml Shared/*.qml Views/*.qml`
|
||||
- `tools/check-load.sh` — serves the repo over HTTP and loads it with `qmlscene` (offscreen, software renderer) like the box does; fails on any Qt warning not coming from libfbxqml. Run it after touching imports, `qmldir` files or singletons.
|
||||
- **Reproduce the box's loading mode**: the Player loads the app over HTTP, which behaves differently from local files (see constraints below). Check with `python3 -m http.server 8765 --directory .` then `QT_QPA_PLATFORM=offscreen qmlscene -I ../libfbxqml http://127.0.0.1:8765/Jellyfin.qml` — it must print no warnings.
|
||||
- The desktop has Qt 5.15 while the box targets QtQuick 2.5: code that runs locally can still use APIs too new for the box.
|
||||
|
||||
**CI** (`.gitea/workflows/ci.yml`, Gitea Actions on the `ubuntu-latest` runner image): on every push/PR, `tools/package.py` (manifest + qmllint + archive) and `tools/check-load.sh`, package uploaded as artifact (`upload-artifact@v3`/`download-artifact@v3`: v4 only works on recent Gitea versions). On tag `vX.Y.Z` matching `manifest.json` `version`, creates a Gitea release with the package attached (API calls with the job's `GITHUB_TOKEN`). Verified locally by replaying the `check` job's steps in a clean `ubuntu:24.04` container; the release job has not run yet.
|
||||
|
||||
**FreeStore package**: `tools/package.py` → `dist/<identifier>.tar.gz` (gitignored). Replicates the QtCreator plugin's "Make FreeStore Package": same file selection as `Jellyfin.fbxproject` (QML/JS/images/fonts/`qmldir`/`manifest.json`, excluding `tools/` and hidden dirs), manifest checks (identifier `\w+(\.\w+)+`, `version` x.y.z equal to `Session.clientVersion`, entry-point files present), `qmllint` on all sources, ustar tar with directory entries, gzipped. Upload is manual on the FreeFactory console (http://factory.free.fr), followed by Free's review.
|
||||
|
||||
**Deploying a test build to the Freebox**: `tools/deploy.py` (Python stdlib only; Player must be in developer mode). It discovers the Player via SSDP (`fbx:devel`) or takes `--box <IP>`, serves the repo over HTTP, calls JSON-RPC `debug_qml_app` on `http://<box>/pub/devel`, and streams the app's stdout/stderr until it exits. `--server <host>` and `--user name[:password]` (both repeatable) serve a virtual `dev-config.json` next to the app; at startup `Session.loadDevConfig()` adds each listed server and stores users in `Session.devUsers`, which `UserSelectView` merges with public users (one-click sign-in when a password is given; never log passwords) (only when the app is loaded over HTTP; 404 otherwise, ignored) — the workaround for the lack of persistence in dev mode. Output is also written to `deploy.log` (repo root, gitignored, overwritten each run) — read it to diagnose on-box failures. The Player fetches files lazily from that HTTP server, so the script must keep running while the app is in use. This replicates the "Run" of the official QtCreator plugin, whose own setup is:
|
||||
|
||||
- SDK setup: https://dev.freebox.fr/sdk/player.html (Windows: https://github.com/fbx/freebox-qtcreator-plugin/issues/8)
|
||||
@@ -28,12 +33,13 @@ There is no build system or test suite.
|
||||
|
||||
## Architecture
|
||||
|
||||
- `Jellyfin.qml` — root `Application`: logo panel (1/3) + `Navigator` (2/3), owns the single `Session` instance.
|
||||
- `Core/Navigator.qml` — screen stack on a `Loader`. `push("Name")` loads `Views/NameView.qml`; also `replace`, `pop`, `reset`. Every view gets `navigator` and `session` injected, plus any props passed to `push`. Remote Back/Escape pops; at the root it propagates (exits app). After loading, focus goes to the view's `initialFocus`.
|
||||
- `Core/Session.qml` — Jellyfin API client over `XMLHttpRequest` (`_request()`: JSON, `Authorization: MediaBrowser …` header with `Token` once signed in, per-request timeout via a dynamically created `Timer` since Qt 5.5 XHR has none). Holds saved servers (`ListModel`, persisted through `fbx.application` `Settings` — works on the box only; on the PC `App is not defined` warnings are expected and nothing persists), `currentServer`, `currentUser`, `accessToken`. Endpoints: `/System/Info/Public` (server probe), `/Users/Public`, `/Users/AuthenticateByName`, `/Sessions/Logout`, `/QuickConnect/*`. Async functions call `callback(error, result)` with `error` a user-facing French message. Every public callback is wrapped by `_guard()`; `cancel()` (called by views on destruction) drops pending callbacks and stops Quick Connect polling.
|
||||
- `Components/` — reusable widgets, listed in `Components/qmldir`.
|
||||
- `Shared/` — `Theme` singleton (colors, spacing, fonts; the only type in `Shared/qmldir`) and `Remote.js` (`.pragma library`, `isAccept`/`isBack` key mapping, imported `as Remote`).
|
||||
- `Views/` — one screen per file, each rooted in `Page` (title/subtitle header + content area). Current flow: `ServerSelect` → `ServerAdd` → `UserSelect` → `Login` (password or Quick Connect) → `Home` (placeholder).
|
||||
- `Jellyfin.qml` — root `Application`: logo panel (1/3) + `Navigator` (2/3), owns the single `Session` instance. The logo panel hides when the current page sets `fullscreen: true` (catalog and player screens).
|
||||
- `Core/Navigator.qml` — screen stack on a `Loader`. `push("Name")` loads `Views/NameView.qml`; also `replace`, `pop`, `reset`. Every view gets `navigator` and `session` injected, plus any props passed to `push`. Remote Back/Escape pops; at the root it propagates (exits app). After loading, focus goes to the view's `initialFocus`. `openItem(item)` routes a catalog item to `Library` / `Season` / `Details`.
|
||||
- `Core/Session.qml` — Jellyfin API client over `XMLHttpRequest` (`_request()`: JSON, `Authorization: MediaBrowser …` header with `Token` once signed in, per-request timeout via a dynamically created `Timer` since Qt 5.5 XHR has none). Holds saved servers (`ListModel`, persisted through `fbx.application` `Settings` — works on the box only; on the PC `App is not defined` warnings are expected and nothing persists), `currentServer`, `currentUser`, `accessToken`. Endpoints: `/System/Info/Public` (server probe: all candidates in parallel, first success in priority order wins so a slow first TLS handshake doesn't fall back to http), `/Users/Public`, `/Users/AuthenticateByName`, `/Sessions/Logout`, `/QuickConnect/*`; catalog `/UserViews`, `/UserItems/Resume`, `/Items/Latest`, `/Items`, `/Shows/{id}/Seasons|Episodes`; playback `/Items/{id}/PlaybackInfo` and `/Sessions/Playing[/Progress|/Stopped]`. API items are flattened by `_toItem()` (no `index` key: reserved role name in `ListModel`). Image URLs via `posterUrl()` / `thumbUrl()` / `backdropUrl()`. Async functions call `callback(error, result)` with `error` a user-facing French message. Every public callback is wrapped by `_guard()`; `cancel()` (called by views on destruction) drops pending callbacks and stops Quick Connect polling.
|
||||
- `Core/DeviceProfile.js` — what the Freebox Player can play, sent in `PlaybackInfo`: direct play H.264 only (the Revolution has no HEVC), otherwise HLS transcode. Text subtitles must stay declared `External` and `SubtitleStreamIndex: -1` sent, or Jellyfin transcodes to burn them in (`SubtitleCodecNotSupported`).
|
||||
- `Components/` — reusable widgets, listed in `Components/qmldir`. `MediaCard` / `MediaRow` for catalog cards and horizontal rows. `VideoSurface` wraps the player: it tries the Freebox native `fbx.media` `VideoPlayer` then QtMultimedia `Video`, both created with `Qt.createQmlObject` so a missing module doesn't break loading; it polls the backend and exposes `position`/`duration` (ms) and `playerState`. **On the box, `fbx.media` is not installed: QtMultimedia is what plays** (verified: HLS transcode, seek/resume, pause, positions in ms). The fbx branch is kept as a fallback but is untested.
|
||||
- `Shared/` — `Theme` singleton (colors, spacing, fonts, card sizes; the only type in `Shared/qmldir`), `Remote.js` (`isAccept`/`isBack` key mapping) and `Format.js` (durations, ticks↔ms, card labels), both `.pragma library`.
|
||||
- `Views/` — one screen per file, each rooted in `Page` (title/subtitle header + content area). Flow: `ServerSelect` → `ServerAdd` → `UserSelect` → `Login` (password or Quick Connect) → `Home` (rows: Reprendre, Mes médias, latest per library) → `Library` (paged poster grid) / `Details` (movie, episode, or series with seasons) → `Season` (episodes) → `Player` (`PlayerView` is a plain `FocusScope`, not a `Page`).
|
||||
|
||||
## Platform constraints
|
||||
|
||||
@@ -47,4 +53,5 @@ There is no build system or test suite.
|
||||
- every imported directory needs a `qmldir` listing all its types (`Core/`, `Components/`, `Shared/`); a missing one gives "X is not a type" only on the box;
|
||||
- a singleton must not live in the same directory as the components that use it, and a directory must hold at most one singleton — otherwise "Cyclic dependency detected". Put helpers in `.pragma library` JS files instead of new singletons;
|
||||
- no `import "."` self-imports.
|
||||
- **Playback reporting must never clobber the server's resume point**: `PlayerView` reports start/progress/stop only once playback actually started *and* the resume position was reached, and never with position 0. (A failed playback reporting a stop at 0 wipes the user's resume position.)
|
||||
- Don't disable (`enabled: false`) a focused control during loading — it loses focus and the remote stops responding; guard with a `busy` flag instead.
|
||||
@@ -0,0 +1,115 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Carte du catalogue : image (affiche ou vignette), titre, sous-titre, avancement.
|
||||
Item {
|
||||
id: card
|
||||
|
||||
property string title: ""
|
||||
property string subtitle: ""
|
||||
property url imageSource: ""
|
||||
property int imageHeight: Theme.posterHeight
|
||||
property real progress: 0
|
||||
property bool played: false
|
||||
property bool highlighted: false
|
||||
property bool showText: true
|
||||
signal clicked()
|
||||
|
||||
height: imageHeight + (showText ? Theme.cardTextHeight : 0)
|
||||
z: highlighted ? 1 : 0
|
||||
|
||||
Rectangle {
|
||||
id: frame
|
||||
width: parent.width
|
||||
height: card.imageHeight
|
||||
radius: Theme.radius
|
||||
color: Theme.surface
|
||||
border.width: card.highlighted ? 3 : 0
|
||||
border.color: Theme.focusBackground
|
||||
scale: card.highlighted ? 1.06 : 1
|
||||
|
||||
Behavior on scale { NumberAnimation { duration: Theme.animFast } }
|
||||
|
||||
// Initiale tant que l'image n'est pas chargée (ou absente).
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: image.status !== Image.Ready
|
||||
text: card.title.charAt(0).toUpperCase()
|
||||
color: Theme.textMuted
|
||||
font.pixelSize: 48
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Image {
|
||||
id: image
|
||||
anchors.fill: parent
|
||||
anchors.margins: frame.border.width
|
||||
source: card.imageSource
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
clip: true
|
||||
sourceSize.height: card.imageHeight
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: card.progress > 0.01 && !card.played
|
||||
anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 8 }
|
||||
height: 4
|
||||
radius: 2
|
||||
color: "#99000000"
|
||||
|
||||
Rectangle {
|
||||
width: parent.width * Math.min(1, card.progress)
|
||||
height: parent.height
|
||||
radius: 2
|
||||
color: Theme.accent
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: card.played
|
||||
anchors { top: parent.top; right: parent.right; margins: 8 }
|
||||
width: playedText.implicitWidth + Theme.spacingS * 2
|
||||
height: playedText.implicitHeight + 4
|
||||
radius: height / 2
|
||||
color: Theme.accent
|
||||
|
||||
Text {
|
||||
id: playedText
|
||||
anchors.centerIn: parent
|
||||
text: "VU"
|
||||
color: Theme.text
|
||||
font.pixelSize: 11
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
visible: card.showText
|
||||
anchors { top: frame.bottom; topMargin: Theme.spacingS; left: parent.left; right: parent.right }
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: card.title
|
||||
elide: Text.ElideRight
|
||||
color: card.highlighted ? Theme.text : Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall + 1
|
||||
font.bold: card.highlighted
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
text: card.subtitle
|
||||
elide: Text.ElideRight
|
||||
color: Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall - 1
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: card.clicked()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Rangée horizontale de cartes avec un titre (accueil, saisons…).
|
||||
// `items` : éléments aplatis par Session._toItem().
|
||||
FocusScope {
|
||||
id: row
|
||||
|
||||
property string title: ""
|
||||
property var items: []
|
||||
property bool landscape: false
|
||||
property var session: null
|
||||
property alias currentIndex: list.currentIndex
|
||||
signal activated(var item)
|
||||
|
||||
readonly property int cardWidth: landscape ? Theme.thumbWidth : Theme.posterWidth
|
||||
readonly property int imageHeight: landscape ? Theme.thumbHeight : Theme.posterHeight
|
||||
|
||||
height: titleText.height + Theme.spacingM + imageHeight + Theme.cardTextHeight + Theme.spacingM
|
||||
|
||||
Text {
|
||||
id: titleText
|
||||
text: row.title
|
||||
color: row.activeFocus ? Theme.text : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: list
|
||||
anchors {
|
||||
top: titleText.bottom
|
||||
topMargin: Theme.spacingM
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.spacingM
|
||||
focus: true
|
||||
// Marge pour la carte agrandie (scale) au bord gauche.
|
||||
leftMargin: 8
|
||||
rightMargin: 8
|
||||
highlightMoveDuration: 150
|
||||
model: row.items
|
||||
|
||||
delegate: MediaCard {
|
||||
width: row.cardWidth
|
||||
imageHeight: row.imageHeight
|
||||
title: Format.cardTitle(modelData)
|
||||
subtitle: Format.cardSubtitle(modelData)
|
||||
imageSource: !row.session ? ""
|
||||
: row.landscape ? row.session.thumbUrl(modelData)
|
||||
: row.session.posterUrl(modelData)
|
||||
progress: Format.progress(modelData)
|
||||
played: modelData.played
|
||||
highlighted: ListView.isCurrentItem && list.activeFocus
|
||||
onClicked: {
|
||||
list.currentIndex = index;
|
||||
row.activated(modelData);
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
row.activated(row.items[currentIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,24 @@ FocusScope {
|
||||
property var session: null
|
||||
// Élément qui reçoit le focus quand l'écran s'affiche.
|
||||
property Item initialFocus: null
|
||||
// true : masque le panneau du logo (écrans du catalogue).
|
||||
property bool fullscreen: false
|
||||
// Image de fond facultative (assombrie).
|
||||
property alias backdrop: backdropImage.source
|
||||
|
||||
property alias title: titleText.text
|
||||
property alias subtitle: subtitleText.text
|
||||
default property alias content: body.data
|
||||
|
||||
Image {
|
||||
id: backdropImage
|
||||
anchors.fill: parent
|
||||
visible: status === Image.Ready
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
opacity: 0.25
|
||||
}
|
||||
|
||||
Column {
|
||||
id: header
|
||||
anchors {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
import QtQuick 2.5
|
||||
|
||||
// Surface vidéo avec une interface unique, quel que soit le lecteur disponible :
|
||||
// - "fbx" : VideoPlayer de libfbxqml (fbx.media) — absent du Freebox Player testé,
|
||||
// conservé en premier choix au cas où, mais jamais vérifié ;
|
||||
// - "qtmultimedia" : Video de QtMultimedia — c'est lui qui lit sur la box (HLS, reprise,
|
||||
// pause et déplacement vérifiés ; positions en millisecondes).
|
||||
// Les deux sont créés dynamiquement : un module absent ne fait pas échouer le chargement.
|
||||
//
|
||||
// position / duration en millisecondes ; playerState : "idle", "loading", "playing",
|
||||
// "paused", "ended" ou "error". Les états bruts du lecteur sont écrits dans le log.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property string source: ""
|
||||
property real position: 0
|
||||
property real duration: 0
|
||||
property string playerState: "idle"
|
||||
property string errorString: ""
|
||||
property string backendName: ""
|
||||
signal ended()
|
||||
|
||||
property var _backend: null
|
||||
property string _lastRaw: ""
|
||||
|
||||
function play() {
|
||||
if (_backend)
|
||||
_backend.play();
|
||||
}
|
||||
|
||||
function pause() {
|
||||
if (_backend)
|
||||
_backend.pause();
|
||||
}
|
||||
|
||||
function togglePause() {
|
||||
if (playerState === "playing")
|
||||
pause();
|
||||
else
|
||||
play();
|
||||
}
|
||||
|
||||
function seek(ms) {
|
||||
if (!_backend)
|
||||
return;
|
||||
var target = Math.max(0, duration > 0 ? Math.min(ms, duration - 1000) : ms);
|
||||
console.log("Lecteur : déplacement à " + Math.round(target / 1000) + " s");
|
||||
_backend.seek(target);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (!_backend)
|
||||
return;
|
||||
_backend.stop();
|
||||
if (backendName === "fbx" && _backend.close)
|
||||
_backend.close();
|
||||
}
|
||||
|
||||
function _create() {
|
||||
var attempts = [
|
||||
{ name: "fbx", qml: 'import QtQuick 2.5; import fbx.media 1.0; VideoPlayer { anchors.fill: parent }' },
|
||||
{ name: "qtmultimedia", qml: 'import QtQuick 2.5; import QtMultimedia 5.0; '
|
||||
+ 'Video { anchors.fill: parent; fillMode: VideoOutput.PreserveAspectFit }' }
|
||||
];
|
||||
for (var i = 0; i < attempts.length && !_backend; i++) {
|
||||
try {
|
||||
_backend = Qt.createQmlObject(attempts[i].qml, root, "VideoSurface-" + attempts[i].name);
|
||||
backendName = attempts[i].name;
|
||||
} catch (e) {
|
||||
console.log("Lecteur " + attempts[i].name + " indisponible : " + e);
|
||||
}
|
||||
}
|
||||
if (!_backend) {
|
||||
_fail("Aucun lecteur vidéo disponible.");
|
||||
return;
|
||||
}
|
||||
console.log("Lecteur vidéo : " + backendName);
|
||||
if (backendName === "fbx" && _backend.error) {
|
||||
_backend.error.connect(function (message, fatal) {
|
||||
console.log("Lecteur fbx : erreur " + message + (fatal ? " (fatale)" : ""));
|
||||
if (fatal)
|
||||
_fail(String(message));
|
||||
});
|
||||
}
|
||||
if (source !== "")
|
||||
_open();
|
||||
}
|
||||
|
||||
function _open() {
|
||||
errorString = "";
|
||||
playerState = "loading";
|
||||
_backend.source = source;
|
||||
_backend.play();
|
||||
}
|
||||
|
||||
function _fail(message) {
|
||||
errorString = message;
|
||||
playerState = "error";
|
||||
}
|
||||
|
||||
// Lecture périodique de l'état du lecteur (identique pour les deux backends).
|
||||
function _poll() {
|
||||
if (!_backend || playerState === "error")
|
||||
return;
|
||||
var raw;
|
||||
if (backendName === "fbx") {
|
||||
raw = "mediaState=" + _backend.mediaState + " playbackState=" + _backend.playbackState
|
||||
+ " status=" + _backend.status;
|
||||
position = _backend.position || 0;
|
||||
duration = _backend.duration || 0;
|
||||
var media = String(_backend.mediaState);
|
||||
var playback = String(_backend.playbackState);
|
||||
if (media === "ended")
|
||||
_setState("ended");
|
||||
else if (playback === "playing")
|
||||
_setState("playing");
|
||||
else if (playback === "paused")
|
||||
_setState("paused");
|
||||
else
|
||||
_setState("loading");
|
||||
} else {
|
||||
// Valeurs de MediaPlayer : playbackState 1 = lecture, 2 = pause ;
|
||||
// status 7 = fin du média, 8 = média invalide.
|
||||
raw = "status=" + _backend.status + " playbackState=" + _backend.playbackState;
|
||||
position = _backend.position || 0;
|
||||
duration = _backend.duration > 0 ? _backend.duration : 0;
|
||||
if (_backend.status === 8 || (_backend.errorString && _backend.error !== 0))
|
||||
_fail(_backend.errorString || "Média illisible.");
|
||||
else if (_backend.status === 7)
|
||||
_setState("ended");
|
||||
else if (_backend.playbackState === 1)
|
||||
_setState(_backend.status === 4 || _backend.status === 5 ? "loading" : "playing");
|
||||
else if (_backend.playbackState === 2)
|
||||
_setState("paused");
|
||||
}
|
||||
if (raw !== _lastRaw) {
|
||||
_lastRaw = raw;
|
||||
console.log("Lecteur " + backendName + " : " + raw + " position=" + Math.round(position)
|
||||
+ " durée=" + Math.round(duration));
|
||||
}
|
||||
}
|
||||
|
||||
function _setState(state) {
|
||||
if (state === playerState)
|
||||
return;
|
||||
playerState = state;
|
||||
if (state === "ended")
|
||||
ended();
|
||||
}
|
||||
|
||||
onSourceChanged: if (_backend && source !== "") _open()
|
||||
|
||||
Timer {
|
||||
interval: 250
|
||||
repeat: true
|
||||
running: root._backend !== null && root.source !== ""
|
||||
onTriggered: root._poll()
|
||||
}
|
||||
|
||||
Component.onCompleted: _create()
|
||||
Component.onDestruction: stop()
|
||||
}
|
||||
@@ -4,3 +4,6 @@ TextField 1.0 TextField.qml
|
||||
ServerItem 1.0 ServerItem.qml
|
||||
UserCard 1.0 UserCard.qml
|
||||
Logo 1.0 Logo.qml
|
||||
MediaCard 1.0 MediaCard.qml
|
||||
MediaRow 1.0 MediaRow.qml
|
||||
VideoSurface 1.0 VideoSurface.qml
|
||||
@@ -0,0 +1,44 @@
|
||||
.pragma library
|
||||
|
||||
// Ce que le Freebox Player (Revolution) sait lire, déclaré à Jellyfin dans PlaybackInfo.
|
||||
// Jellyfin choisit alors : lecture directe si le fichier convient, sinon transcodage HLS.
|
||||
// Hypothèses prudentes (H.264 seulement : pas de HEVC sur la Revolution), à ajuster
|
||||
// d'après les essais sur la box.
|
||||
|
||||
var maxBitrate = 20000000;
|
||||
|
||||
function profile() {
|
||||
return {
|
||||
Name: "Freebox Player",
|
||||
MaxStreamingBitrate: maxBitrate,
|
||||
MaxStaticBitrate: maxBitrate,
|
||||
DirectPlayProfiles: [
|
||||
{ Type: "Video", Container: "mp4,m4v,mkv,ts,mov", VideoCodec: "h264", AudioCodec: "aac,mp3,ac3" }
|
||||
],
|
||||
TranscodingProfiles: [
|
||||
{
|
||||
Type: "Video", Container: "ts", Protocol: "hls", Context: "Streaming",
|
||||
VideoCodec: "h264", AudioCodec: "aac,ac3", MaxAudioChannels: "6",
|
||||
MinSegments: 1, BreakOnNonKeyFrames: true
|
||||
}
|
||||
],
|
||||
CodecProfiles: [
|
||||
{
|
||||
Type: "Video", Codec: "h264",
|
||||
Conditions: [
|
||||
{ Condition: "LessThanEqual", Property: "Width", Value: "1920" },
|
||||
{ Condition: "LessThanEqual", Property: "VideoBitDepth", Value: "8" }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Sous-titres texte déclarés « externes » : sans ça, Jellyfin transcode pour les
|
||||
// incruster (SubtitleCodecNotSupported). Le lecteur ne les affiche pas encore.
|
||||
SubtitleProfiles: [
|
||||
{ Format: "srt", Method: "External" },
|
||||
{ Format: "subrip", Method: "External" },
|
||||
{ Format: "ass", Method: "External" },
|
||||
{ Format: "ssa", Method: "External" },
|
||||
{ Format: "vtt", Method: "External" }
|
||||
]
|
||||
};
|
||||
}
|
||||
@@ -10,6 +10,7 @@ FocusScope {
|
||||
|
||||
property var session: null
|
||||
property int depth: 0
|
||||
readonly property bool fullscreen: loader.item !== null && loader.item.fullscreen === true
|
||||
property var _stack: []
|
||||
|
||||
function push(name, props) {
|
||||
@@ -36,6 +37,17 @@ FocusScope {
|
||||
push(name, props);
|
||||
}
|
||||
|
||||
// Ouvre l'écran adapté à un élément du catalogue (Session._toItem()).
|
||||
function openItem(item) {
|
||||
if (item.type === "CollectionFolder")
|
||||
push("Library", { library: { id: item.id, name: item.name, collectionType: item.collectionType } });
|
||||
else if (item.type === "Season")
|
||||
push("Season", { seriesId: item.seriesId, seasonId: item.id, seasonName: item.name,
|
||||
seriesName: item.seriesName });
|
||||
else
|
||||
push("Details", { itemId: item.id });
|
||||
}
|
||||
|
||||
function _load() {
|
||||
var entry = _stack[_stack.length - 1];
|
||||
var props = { navigator: root, session: root.session };
|
||||
|
||||
+240
-10
@@ -1,5 +1,6 @@
|
||||
import QtQuick 2.5
|
||||
import fbx.application 1.0
|
||||
import "DeviceProfile.js" as DeviceProfile
|
||||
|
||||
// État de connexion et appels à l'API Jellyfin : serveurs enregistrés,
|
||||
// serveur et utilisateur courants, jeton d'accès.
|
||||
@@ -9,6 +10,7 @@ QtObject {
|
||||
id: session
|
||||
|
||||
readonly property string clientName: "Jellyfin Freebox"
|
||||
// Doit rester égale à « version » dans manifest.json (vérifié par tools/package.py).
|
||||
readonly property string clientVersion: "0.1.0"
|
||||
readonly property string deviceName: "Freebox Player"
|
||||
|
||||
@@ -59,7 +61,7 @@ QtObject {
|
||||
callback("Le port doit être un nombre entre 1 et 65535.");
|
||||
return;
|
||||
}
|
||||
_probeCandidates(serverCandidates(host, portText), 0, function (err, server) {
|
||||
_probeCandidates(serverCandidates(host, portText), function (err, server) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@@ -229,6 +231,207 @@ QtObject {
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- Catalogue
|
||||
// Les éléments renvoyés sont « aplatis » par _toItem() (voir ses champs) pour
|
||||
// pouvoir aller tels quels dans un ListModel ou un modèle JS.
|
||||
|
||||
// Bibliothèques de l'utilisateur : Films, Séries…
|
||||
function loadLibraries(callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/UserViews?" + _query({ userId: currentUser.id }), null, function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? [] : _toItems(data.Items));
|
||||
});
|
||||
}
|
||||
|
||||
// « Reprendre » : vidéos commencées.
|
||||
function loadResume(callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/UserItems/Resume?" + _query({
|
||||
userId: currentUser.id, limit: 20, mediaTypes: "Video", enableTotalRecordCount: false
|
||||
}), null, function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? [] : _toItems(data.Items));
|
||||
});
|
||||
}
|
||||
|
||||
// Derniers ajouts d'une bibliothèque.
|
||||
function loadLatest(libraryId, callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/Items/Latest?" + _query({ userId: currentUser.id, parentId: libraryId, limit: 20 }),
|
||||
null, function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? [] : _toItems(data));
|
||||
});
|
||||
}
|
||||
|
||||
// Contenu d'une bibliothèque, par pages. callback(err, items, total)
|
||||
function loadLibraryItems(library, startIndex, limit, callback) {
|
||||
callback = _guard(callback);
|
||||
var types = library.collectionType === "tvshows" ? "Series"
|
||||
: library.collectionType === "movies" ? "Movie" : "Movie,Series,Video";
|
||||
_request("GET", "/Items?" + _query({
|
||||
userId: currentUser.id, parentId: library.id, recursive: true, includeItemTypes: types,
|
||||
sortBy: "SortName", sortOrder: "Ascending", startIndex: startIndex, limit: limit,
|
||||
fields: "PrimaryImageAspectRatio"
|
||||
}), null, function (err, data) {
|
||||
if (err)
|
||||
callback(_describe(err), [], 0);
|
||||
else
|
||||
callback(null, _toItems(data.Items), data.TotalRecordCount || 0);
|
||||
});
|
||||
}
|
||||
|
||||
function loadItem(itemId, callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/Items/" + itemId + "?" + _query({ userId: currentUser.id }), null, function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? null : _toItem(data));
|
||||
});
|
||||
}
|
||||
|
||||
function loadSeasons(seriesId, callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/Shows/" + seriesId + "/Seasons?" + _query({ userId: currentUser.id }), null,
|
||||
function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? [] : _toItems(data.Items));
|
||||
});
|
||||
}
|
||||
|
||||
function loadEpisodes(seriesId, seasonId, callback) {
|
||||
callback = _guard(callback);
|
||||
_request("GET", "/Shows/" + seriesId + "/Episodes?" + _query({
|
||||
userId: currentUser.id, seasonId: seasonId, fields: "Overview"
|
||||
}), null, function (err, data) {
|
||||
callback(err ? _describe(err) : null, err ? [] : _toItems(data.Items));
|
||||
});
|
||||
}
|
||||
|
||||
// URL d'image (pas d'authentification nécessaire). kind : "Primary", "Backdrop", "Thumb".
|
||||
function imageUrl(itemId, kind, tag, maxHeight) {
|
||||
if (!currentServer || !itemId || !tag)
|
||||
return "";
|
||||
return currentServer.address + "/Items/" + itemId + "/Images/" + kind + "?"
|
||||
+ _query({ tag: tag, maxHeight: maxHeight || 360, quality: 90 });
|
||||
}
|
||||
|
||||
// Affiche : celle de l'élément, sinon celle de sa série.
|
||||
function posterUrl(item, maxHeight) {
|
||||
if (item.imageTag)
|
||||
return imageUrl(item.id, "Primary", item.imageTag, maxHeight);
|
||||
return imageUrl(item.seriesId, "Primary", item.seriesPrimaryTag, maxHeight);
|
||||
}
|
||||
|
||||
// Vignette 16:9 : image principale des bibliothèques/épisodes, sinon Thumb, sinon fond.
|
||||
function thumbUrl(item, maxHeight) {
|
||||
maxHeight = maxHeight || 300;
|
||||
if ((item.type === "CollectionFolder" || item.type === "Episode") && item.imageTag)
|
||||
return imageUrl(item.id, "Primary", item.imageTag, maxHeight);
|
||||
if (item.thumbTag)
|
||||
return imageUrl(item.id, "Thumb", item.thumbTag, maxHeight);
|
||||
return backdropUrl(item, maxHeight) || posterUrl(item, maxHeight);
|
||||
}
|
||||
|
||||
function backdropUrl(item, maxHeight) {
|
||||
if (item.backdropTag)
|
||||
return imageUrl(item.id, "Backdrop", item.backdropTag, maxHeight || 720);
|
||||
return imageUrl(item.parentBackdropItemId, "Backdrop", item.parentBackdropTag, maxHeight || 720);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------- Lecture
|
||||
|
||||
// Demande à Jellyfin comment lire l'élément pour ce Player (profil DeviceProfile.js).
|
||||
// callback(err, { url, itemId, mediaSourceId, playSessionId, playMethod })
|
||||
function preparePlayback(itemId, callback) {
|
||||
callback = _guard(callback);
|
||||
_request("POST", "/Items/" + itemId + "/PlaybackInfo?" + _query({ userId: currentUser.id }),
|
||||
// SubtitleStreamIndex -1 : pas de sous-titres (évite leur incrustation par transcodage).
|
||||
{ DeviceProfile: DeviceProfile.profile(), MaxStreamingBitrate: DeviceProfile.maxBitrate,
|
||||
SubtitleStreamIndex: -1 },
|
||||
function (err, data) {
|
||||
if (err) {
|
||||
callback(_describe(err));
|
||||
return;
|
||||
}
|
||||
var source = data.MediaSources && data.MediaSources[0];
|
||||
if (data.ErrorCode || !source) {
|
||||
callback("Lecture impossible (" + (data.ErrorCode || "aucune source") + ").");
|
||||
return;
|
||||
}
|
||||
var info = { itemId: itemId, mediaSourceId: source.Id, playSessionId: data.PlaySessionId };
|
||||
if (source.SupportsDirectPlay || source.SupportsDirectStream) {
|
||||
info.playMethod = source.SupportsDirectPlay ? "DirectPlay" : "DirectStream";
|
||||
info.url = currentServer.address + "/Videos/" + itemId + "/stream?" + _query({
|
||||
static: true, mediaSourceId: source.Id, playSessionId: data.PlaySessionId,
|
||||
deviceId: _settings.deviceId, api_key: accessToken
|
||||
});
|
||||
} else if (source.SupportsTranscoding && source.TranscodingUrl) {
|
||||
info.playMethod = "Transcode";
|
||||
info.url = currentServer.address + source.TranscodingUrl;
|
||||
} else {
|
||||
callback("Ce média ne peut pas être lu sur la Freebox.");
|
||||
return;
|
||||
}
|
||||
console.log("Lecture : " + info.playMethod + " (" + (source.Container || "?") + ")");
|
||||
callback(null, info);
|
||||
});
|
||||
}
|
||||
|
||||
// Suivi de lecture côté serveur (reprise, « vu »). event : "start", "progress", "stop".
|
||||
function reportPlayback(event, info, positionMs, paused) {
|
||||
var path = event === "start" ? "/Sessions/Playing"
|
||||
: event === "stop" ? "/Sessions/Playing/Stopped" : "/Sessions/Playing/Progress";
|
||||
_request("POST", path, {
|
||||
ItemId: info.itemId, MediaSourceId: info.mediaSourceId, PlaySessionId: info.playSessionId,
|
||||
PlayMethod: info.playMethod, PositionTicks: Math.floor((positionMs || 0) * 10000),
|
||||
IsPaused: !!paused, CanSeek: true
|
||||
}, function () {});
|
||||
}
|
||||
|
||||
function _query(params) {
|
||||
var parts = [];
|
||||
for (var key in params) {
|
||||
if (params[key] !== undefined && params[key] !== null && params[key] !== "")
|
||||
parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
|
||||
}
|
||||
return parts.join("&");
|
||||
}
|
||||
|
||||
function _toItems(list) {
|
||||
var items = [];
|
||||
for (var i = 0; i < (list || []).length; i++)
|
||||
items.push(_toItem(list[i]));
|
||||
return items;
|
||||
}
|
||||
|
||||
function _toItem(i) {
|
||||
var userData = i.UserData || {};
|
||||
return {
|
||||
id: i.Id,
|
||||
name: i.Name || "",
|
||||
type: i.Type || "",
|
||||
collectionType: i.CollectionType || "",
|
||||
isFolder: !!i.IsFolder,
|
||||
year: i.ProductionYear || 0,
|
||||
overview: i.Overview || "",
|
||||
runtimeTicks: i.RunTimeTicks || 0,
|
||||
rating: i.OfficialRating || "",
|
||||
communityRating: i.CommunityRating || 0,
|
||||
imageTag: (i.ImageTags && i.ImageTags.Primary) || "",
|
||||
thumbTag: (i.ImageTags && i.ImageTags.Thumb) || "",
|
||||
backdropTag: (i.BackdropImageTags && i.BackdropImageTags[0]) || "",
|
||||
parentBackdropItemId: i.ParentBackdropItemId || "",
|
||||
parentBackdropTag: (i.ParentBackdropImageTags && i.ParentBackdropImageTags[0]) || "",
|
||||
seriesId: i.SeriesId || "",
|
||||
seriesName: i.SeriesName || "",
|
||||
seriesPrimaryTag: i.SeriesPrimaryImageTag || "",
|
||||
seasonId: i.SeasonId || "",
|
||||
// (pas de champ « index » : rôle réservé dans les ListModel)
|
||||
indexNumber: i.IndexNumber || 0,
|
||||
parentIndexNumber: i.ParentIndexNumber || 0,
|
||||
childCount: i.ChildCount || 0,
|
||||
positionTicks: userData.PlaybackPositionTicks || 0,
|
||||
playedPercentage: userData.PlayedPercentage || 0,
|
||||
played: !!userData.Played
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ Divers
|
||||
|
||||
// Ignore les réponses en attente (appelé quand un écran est détruit).
|
||||
@@ -253,20 +456,47 @@ QtObject {
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
// Essaie les adresses une par une ; renvoie la première qui répond comme un serveur Jellyfin.
|
||||
function _probeCandidates(candidates, index, callback) {
|
||||
if (index >= candidates.length) {
|
||||
// Essaie toutes les adresses en parallèle et retient la première, dans l'ordre de
|
||||
// priorité, qui répond comme un serveur Jellyfin. Une adresse moins prioritaire (http)
|
||||
// n'est retenue qu'une fois les plus prioritaires (https) réellement en échec : un
|
||||
// premier échange TLS lent (chargement des certificats, CPU de la box) ne doit pas
|
||||
// faire basculer sur http.
|
||||
function _probeCandidates(candidates, callback) {
|
||||
var results = [];
|
||||
var settled = false;
|
||||
|
||||
function settle() {
|
||||
if (settled)
|
||||
return;
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
if (results[i] === undefined)
|
||||
return; // une adresse plus prioritaire n'a pas encore répondu
|
||||
if (results[i]) {
|
||||
settled = true;
|
||||
callback(null, results[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
settled = true;
|
||||
callback("Aucun serveur Jellyfin trouvé à cette adresse.");
|
||||
}
|
||||
|
||||
if (candidates.length === 0) {
|
||||
callback("Aucun serveur Jellyfin trouvé à cette adresse.");
|
||||
return;
|
||||
}
|
||||
var address = candidates[index];
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
(function (index, address) {
|
||||
_request("GET", "/System/Info/Public", null, function (err, info) {
|
||||
if (!err && info && info.Id) {
|
||||
callback(null, { name: info.ServerName || _hostOf(address), address: address, id: info.Id });
|
||||
return;
|
||||
results[index] = !err && info && info.Id
|
||||
? { name: info.ServerName || _hostOf(address), address: address, id: info.Id }
|
||||
: null;
|
||||
if (!results[index])
|
||||
console.log("Serveur : " + address + " ne répond pas (" + (err ? err.kind + " " + err.status : "réponse inattendue") + ")");
|
||||
settle();
|
||||
}, { baseUrl: address, timeout: 10000 });
|
||||
})(i, candidates[i]);
|
||||
}
|
||||
_probeCandidates(candidates, index + 1, callback);
|
||||
}, { baseUrl: address, timeout: 5000 });
|
||||
}
|
||||
|
||||
function _describe(err) {
|
||||
|
||||
+3
-1
@@ -17,9 +17,11 @@ Application {
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
|
||||
// Masqué sur les écrans du catalogue (Page.fullscreen).
|
||||
Logo {
|
||||
id: logo
|
||||
width: parent.width / 3
|
||||
visible: !navigator.fullscreen
|
||||
width: visible ? parent.width / 3 : 0
|
||||
height: parent.height
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
.pragma library
|
||||
|
||||
// Mise en forme des durées et des libellés de médias.
|
||||
|
||||
var TICKS_PER_MS = 10000; // Jellyfin compte en « ticks » de 100 ns
|
||||
|
||||
function ticksToMs(ticks) {
|
||||
return Math.floor((ticks || 0) / TICKS_PER_MS);
|
||||
}
|
||||
|
||||
function msToTicks(ms) {
|
||||
return Math.floor((ms || 0) * TICKS_PER_MS);
|
||||
}
|
||||
|
||||
// « 1 h 34 min », « 52 min »
|
||||
function runtime(ticks) {
|
||||
var minutes = Math.round(ticksToMs(ticks) / 60000);
|
||||
if (minutes <= 0)
|
||||
return "";
|
||||
if (minutes < 60)
|
||||
return minutes + " min";
|
||||
var m = minutes % 60;
|
||||
return Math.floor(minutes / 60) + " h" + (m > 0 ? " " + (m < 10 ? "0" : "") + m + " min" : "");
|
||||
}
|
||||
|
||||
// « 1:02:03 », « 4:05 »
|
||||
function clock(ms) {
|
||||
var total = Math.max(0, Math.floor((ms || 0) / 1000));
|
||||
var h = Math.floor(total / 3600);
|
||||
var m = Math.floor((total % 3600) / 60);
|
||||
var s = total % 60;
|
||||
var mm = h > 0 && m < 10 ? "0" + m : String(m);
|
||||
return (h > 0 ? h + ":" : "") + mm + ":" + (s < 10 ? "0" : "") + s;
|
||||
}
|
||||
|
||||
// « S1 · É3 » pour un épisode
|
||||
function episodeCode(item) {
|
||||
if (!item || item.type !== "Episode")
|
||||
return "";
|
||||
return "S" + (item.parentIndexNumber || 0) + " · É" + (item.indexNumber || 0);
|
||||
}
|
||||
|
||||
// Libellés des cartes du catalogue.
|
||||
function cardTitle(item) {
|
||||
return item.type === "Episode" && item.seriesName ? item.seriesName : item.name;
|
||||
}
|
||||
|
||||
function cardSubtitle(item) {
|
||||
if (item.type === "Episode")
|
||||
return episodeCode(item) + " – " + item.name;
|
||||
if (item.type === "Series" && item.childCount)
|
||||
return item.childCount + " saison" + (item.childCount > 1 ? "s" : "");
|
||||
return item.year ? String(item.year) : "";
|
||||
}
|
||||
|
||||
// Avancement 0..1 (pour la barre de progression des cartes).
|
||||
function progress(item) {
|
||||
if (item.playedPercentage)
|
||||
return item.playedPercentage / 100;
|
||||
return item.runtimeTicks ? item.positionTicks / item.runtimeTicks : 0;
|
||||
}
|
||||
|
||||
// Ligne d'informations : « 1997 · 1 h 34 min · Tous publics »
|
||||
function infoLine(item) {
|
||||
var parts = [];
|
||||
if (item.type === "Episode")
|
||||
parts.push(episodeCode(item));
|
||||
if (item.year)
|
||||
parts.push(String(item.year));
|
||||
if (item.runtimeTicks)
|
||||
parts.push(runtime(item.runtimeTicks));
|
||||
if (item.rating)
|
||||
parts.push(item.rating);
|
||||
if (item.communityRating)
|
||||
parts.push(item.communityRating.toFixed(1).replace(".", ",") + "/10");
|
||||
return parts.join(" · ");
|
||||
}
|
||||
@@ -31,6 +31,13 @@ QtObject {
|
||||
readonly property int fontTitle: 32
|
||||
readonly property int fontCode: 56
|
||||
|
||||
// Cartes du catalogue (affiche 2:3, vignette 16:9)
|
||||
readonly property int posterWidth: 150
|
||||
readonly property int posterHeight: 225
|
||||
readonly property int thumbWidth: 267
|
||||
readonly property int thumbHeight: 150
|
||||
readonly property int cardTextHeight: 52
|
||||
|
||||
// Contrôles
|
||||
readonly property int controlHeight: 48
|
||||
readonly property int radius: 6
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Fiche d'un film, d'un épisode ou d'une série (saisons).
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string itemId: ""
|
||||
property var item: null
|
||||
property var seasons: []
|
||||
property string error: ""
|
||||
|
||||
readonly property bool isSeries: item !== null && item.type === "Series"
|
||||
readonly property real resumeMs: item ? Format.ticksToMs(item.positionTicks) : 0
|
||||
|
||||
fullscreen: true
|
||||
title: item ? item.name : ""
|
||||
subtitle: item ? (item.type === "Episode" && item.seriesName ? item.seriesName + " · " : "")
|
||||
+ Format.infoLine(item) : ""
|
||||
backdrop: item && page.session ? page.session.backdropUrl(item, 720) : ""
|
||||
initialFocus: playButton
|
||||
|
||||
function play(startMs) {
|
||||
var label = item.type === "Episode"
|
||||
? item.seriesName + " · " + Format.episodeCode(item) + " – " + item.name : item.name;
|
||||
page.navigator.push("Player", { itemId: item.id, title: label, startMs: startMs });
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
page.session.loadItem(itemId, function (err, loaded) {
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.item = loaded;
|
||||
if (loaded.type === "Series") {
|
||||
page.session.loadSeasons(loaded.id, function (e, list) {
|
||||
page.seasons = list;
|
||||
seasonsRow.forceActiveFocus();
|
||||
});
|
||||
} else {
|
||||
playButton.forceActiveFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
Rectangle {
|
||||
id: poster
|
||||
width: 200
|
||||
height: 300
|
||||
radius: Theme.radius
|
||||
color: Theme.surface
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
// Épisode : affiche de la série (l'image de l'épisode est en 16:9).
|
||||
source: !page.item || !page.session ? ""
|
||||
: page.item.type === "Episode" && page.item.seriesPrimaryTag
|
||||
? page.session.imageUrl(page.item.seriesId, "Primary", page.item.seriesPrimaryTag, 450)
|
||||
: page.session.posterUrl(page.item, 450)
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
sourceSize.height: 300
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors {
|
||||
left: poster.right
|
||||
leftMargin: Theme.spacingXL
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
}
|
||||
spacing: Theme.spacingL
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
text: page.error !== "" ? page.error : page.item ? page.item.overview : "Chargement…"
|
||||
color: page.error !== "" ? Theme.error : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: page.isSeries ? 4 : 8
|
||||
elide: Text.ElideRight
|
||||
lineHeight: 1.15
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingM
|
||||
visible: page.item !== null && !page.isSeries
|
||||
|
||||
FocusButton {
|
||||
id: playButton
|
||||
primary: true
|
||||
text: page.resumeMs > 0 ? "Reprendre à " + Format.clock(page.resumeMs) : "Lire"
|
||||
KeyNavigation.right: restartButton.visible ? restartButton : null
|
||||
onClicked: page.play(page.resumeMs)
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: restartButton
|
||||
visible: page.resumeMs > 0
|
||||
text: "Lire depuis le début"
|
||||
KeyNavigation.left: playButton
|
||||
onClicked: page.play(0)
|
||||
}
|
||||
}
|
||||
|
||||
MediaRow {
|
||||
id: seasonsRow
|
||||
width: parent.width
|
||||
visible: page.seasons.length > 0
|
||||
title: "Saisons"
|
||||
items: page.seasons
|
||||
session: page.session
|
||||
onActivated: page.navigator.openItem(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
+105
-15
@@ -3,27 +3,75 @@ import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Écran d'accueil provisoire : confirme la connexion en attendant la vraie bibliothèque.
|
||||
// Accueil : rangées « Reprendre », « Mes médias » et derniers ajouts de chaque bibliothèque.
|
||||
// Toutes les rangées sont chargées avant affichage, pour ne pas déplacer le focus en cours de route.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
title: page.session && page.session.currentUser
|
||||
? "Bonjour " + page.session.currentUser.name
|
||||
: "Accueil"
|
||||
subtitle: page.session && page.session.currentServer
|
||||
? "Connecté à " + page.session.currentServer.name + "."
|
||||
: ""
|
||||
initialFocus: backButton
|
||||
property var rows: []
|
||||
property bool loading: true
|
||||
property string error: ""
|
||||
|
||||
// La pile a été réinitialisée à la connexion : on reconstruit Serveurs > Utilisateurs
|
||||
// pour revenir au choix de l'utilisateur.
|
||||
fullscreen: true
|
||||
title: page.session && page.session.currentUser ? "Bonjour " + page.session.currentUser.name : "Accueil"
|
||||
subtitle: page.session && page.session.currentServer ? page.session.currentServer.name : ""
|
||||
initialFocus: switchUserButton
|
||||
|
||||
// La pile a été réinitialisée à la connexion : on reconstruit Serveurs > Utilisateurs.
|
||||
function goBack() {
|
||||
page.navigator.reset("ServerSelect");
|
||||
page.navigator.push("UserSelect");
|
||||
}
|
||||
|
||||
// La touche Retour de la télécommande fait la même chose que le bouton
|
||||
// (sinon, à la racine de la pile, elle fermerait l'application).
|
||||
function load() {
|
||||
page.session.loadLibraries(function (err, libraries) {
|
||||
if (err) {
|
||||
page.error = err;
|
||||
page.loading = false;
|
||||
return;
|
||||
}
|
||||
var resume = [];
|
||||
var latest = [];
|
||||
var pending = 1 + libraries.length;
|
||||
function done() {
|
||||
if (--pending === 0)
|
||||
page.build(libraries, resume, latest);
|
||||
}
|
||||
page.session.loadResume(function (e, items) {
|
||||
resume = items;
|
||||
done();
|
||||
});
|
||||
for (var i = 0; i < libraries.length; i++) {
|
||||
(function (index) {
|
||||
page.session.loadLatest(libraries[index].id, function (e, items) {
|
||||
latest[index] = items;
|
||||
done();
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function build(libraries, resume, latest) {
|
||||
var list = [];
|
||||
if (resume.length > 0)
|
||||
list.push({ title: "Reprendre", items: resume, landscape: true });
|
||||
if (libraries.length > 0)
|
||||
list.push({ title: "Mes médias", items: libraries, landscape: true });
|
||||
for (var i = 0; i < libraries.length; i++) {
|
||||
if (latest[i] && latest[i].length > 0)
|
||||
list.push({ title: "Ajouts récents · " + libraries[i].name, items: latest[i], landscape: false });
|
||||
}
|
||||
rows = list;
|
||||
loading = false;
|
||||
if (list.length > 0)
|
||||
rowsList.forceActiveFocus();
|
||||
}
|
||||
|
||||
Component.onCompleted: load()
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
// Retour : choix de l'utilisateur (sinon, à la racine de la pile, l'app se fermerait).
|
||||
Keys.onPressed: {
|
||||
if (Remote.isBack(event.key)) {
|
||||
event.accepted = true;
|
||||
@@ -32,23 +80,65 @@ Page {
|
||||
}
|
||||
|
||||
Row {
|
||||
id: actions
|
||||
spacing: Theme.spacingM
|
||||
|
||||
FocusButton {
|
||||
id: backButton
|
||||
text: "Retour"
|
||||
id: switchUserButton
|
||||
text: "Changer d'utilisateur"
|
||||
KeyNavigation.right: logoutButton
|
||||
KeyNavigation.down: rowsList
|
||||
onClicked: page.goBack()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: logoutButton
|
||||
text: "Se déconnecter"
|
||||
KeyNavigation.left: backButton
|
||||
KeyNavigation.left: switchUserButton
|
||||
KeyNavigation.down: rowsList
|
||||
onClicked: {
|
||||
page.session.logout();
|
||||
page.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: rowsList
|
||||
anchors {
|
||||
top: actions.bottom
|
||||
topMargin: Theme.spacingL
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
clip: true
|
||||
spacing: Theme.spacingS
|
||||
model: page.rows
|
||||
|
||||
delegate: MediaRow {
|
||||
width: rowsList.width
|
||||
title: modelData.title
|
||||
items: modelData.items
|
||||
landscape: modelData.landscape
|
||||
session: page.session
|
||||
onActivated: page.navigator.openItem(item)
|
||||
}
|
||||
|
||||
// La rangée courante reste en haut de la zone visible.
|
||||
onCurrentIndexChanged: positionViewAtIndex(currentIndex, ListView.Beginning)
|
||||
|
||||
KeyNavigation.priority: KeyNavigation.AfterItem
|
||||
KeyNavigation.up: switchUserButton
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: rowsList
|
||||
visible: text !== ""
|
||||
text: page.loading ? "Chargement…"
|
||||
: page.error !== "" ? page.error
|
||||
: page.rows.length === 0 ? "Aucun média disponible pour ce compte." : ""
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Contenu d'une bibliothèque en grille d'affiches, chargé par pages à mesure qu'on descend.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property var library: null // { id, name, collectionType }
|
||||
property int total: 0
|
||||
property bool loading: false
|
||||
property string error: ""
|
||||
|
||||
readonly property int pageSize: 60
|
||||
|
||||
fullscreen: true
|
||||
title: library ? library.name : ""
|
||||
subtitle: total > 0 ? total + " élément" + (total > 1 ? "s" : "") : ""
|
||||
initialFocus: grid
|
||||
|
||||
function loadMore() {
|
||||
if (loading || (total > 0 && itemsModel.count >= total))
|
||||
return;
|
||||
loading = true;
|
||||
page.session.loadLibraryItems(library, itemsModel.count, pageSize, function (err, items, count) {
|
||||
page.loading = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.total = count;
|
||||
for (var i = 0; i < items.length; i++)
|
||||
itemsModel.append(items[i]);
|
||||
});
|
||||
}
|
||||
|
||||
Component.onCompleted: loadMore()
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
ListModel {
|
||||
id: itemsModel
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: grid
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
focus: true
|
||||
// Marges pour la carte agrandie (scale).
|
||||
leftMargin: 8
|
||||
topMargin: 8
|
||||
cellWidth: Theme.posterWidth + Theme.spacingL
|
||||
cellHeight: Theme.posterHeight + Theme.cardTextHeight + Theme.spacingL
|
||||
model: itemsModel
|
||||
|
||||
delegate: MediaCard {
|
||||
width: Theme.posterWidth
|
||||
title: model.name
|
||||
subtitle: Format.cardSubtitle(model)
|
||||
imageSource: page.session ? page.session.posterUrl(model) : ""
|
||||
progress: Format.progress(model)
|
||||
played: model.played
|
||||
highlighted: GridView.isCurrentItem && grid.activeFocus
|
||||
onClicked: {
|
||||
grid.currentIndex = index;
|
||||
page.navigator.openItem(itemsModel.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
// Page suivante quand on approche de la fin.
|
||||
onCurrentIndexChanged: if (currentIndex >= count - 14) page.loadMore()
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.navigator.openItem(itemsModel.get(currentIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: text !== ""
|
||||
text: page.error !== "" ? page.error
|
||||
: itemsModel.count === 0 ? (page.loading ? "Chargement…" : "Cette bibliothèque est vide.") : ""
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Lecteur plein écran.
|
||||
// Télécommande : OK = lecture/pause, Gauche/Droite = -10 s/+30 s, Haut/Bas = afficher les
|
||||
// informations, Retour = quitter (géré par le Navigator).
|
||||
// La progression est signalée au serveur (reprise, « vu ») au démarrage, toutes les 10 s et à l'arrêt.
|
||||
FocusScope {
|
||||
id: player
|
||||
|
||||
// Injectés par le Navigator
|
||||
property var navigator: null
|
||||
property var session: null
|
||||
property Item initialFocus: null
|
||||
property bool fullscreen: true
|
||||
|
||||
// Paramètres de push("Player", …)
|
||||
property string itemId: ""
|
||||
property string title: ""
|
||||
property real startMs: 0
|
||||
|
||||
property var info: null // résultat de Session.preparePlayback()
|
||||
property bool started: false // lecture effectivement démarrée et signalée
|
||||
property bool resumed: false
|
||||
// Reprise atteinte (ou lecture depuis le début) : avant ça, on ne signale rien, pour
|
||||
// ne pas écraser le point de reprise si le déplacement initial échoue.
|
||||
property bool resumeReached: startMs <= 0
|
||||
property bool finished: false
|
||||
property string error: ""
|
||||
|
||||
function showOsd() {
|
||||
osd.shown = true;
|
||||
osdTimer.restart();
|
||||
}
|
||||
|
||||
function seekBy(deltaMs) {
|
||||
if (video.duration <= 0)
|
||||
return;
|
||||
video.seek(video.position + deltaMs);
|
||||
showOsd();
|
||||
}
|
||||
|
||||
// Rien n'est signalé tant que la lecture n'a pas réellement démarré : un arrêt
|
||||
// signalé à la position 0 effacerait le point de reprise sur le serveur.
|
||||
function report(event) {
|
||||
if (!player.info || !player.started)
|
||||
return;
|
||||
if (event !== "start" && video.position <= 0)
|
||||
return;
|
||||
player.session.reportPlayback(event, player.info, video.position, video.playerState === "paused");
|
||||
}
|
||||
|
||||
// Signale le démarrage une fois la lecture lancée ET la position de reprise atteinte.
|
||||
function maybeReportStart() {
|
||||
if (player.started || !player.info || video.playerState !== "playing" || !player.resumeReached)
|
||||
return;
|
||||
player.started = true;
|
||||
player.report("start");
|
||||
}
|
||||
|
||||
function finish() {
|
||||
if (finished)
|
||||
return;
|
||||
finished = true;
|
||||
report("stop");
|
||||
player.navigator.pop();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
showOsd();
|
||||
player.session.preparePlayback(itemId, function (err, playback) {
|
||||
if (err) {
|
||||
player.error = err;
|
||||
return;
|
||||
}
|
||||
player.info = playback;
|
||||
video.source = playback.url;
|
||||
});
|
||||
}
|
||||
|
||||
// Retour (le Navigator dépile) ou fin : on signale l'arrêt au serveur.
|
||||
Component.onDestruction: {
|
||||
if (!finished) {
|
||||
finished = true;
|
||||
report("stop");
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
var key = event.key;
|
||||
if (Remote.isAccept(key) || key === Qt.Key_Space || key === Qt.Key_MediaTogglePlayPause
|
||||
|| key === Qt.Key_MediaPlay || key === Qt.Key_MediaPause) {
|
||||
video.togglePause();
|
||||
showOsd();
|
||||
} else if (key === Qt.Key_Left || key === Qt.Key_AudioRewind) {
|
||||
seekBy(-10000);
|
||||
} else if (key === Qt.Key_Right || key === Qt.Key_AudioForward) {
|
||||
seekBy(30000);
|
||||
} else if (key === Qt.Key_Up || key === Qt.Key_Down) {
|
||||
showOsd();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
}
|
||||
|
||||
VideoSurface {
|
||||
id: video
|
||||
anchors.fill: parent
|
||||
|
||||
onPlayerStateChanged: {
|
||||
player.maybeReportStart();
|
||||
if (playerState === "paused")
|
||||
player.showOsd();
|
||||
}
|
||||
// Reprise : déplacement une fois la durée connue.
|
||||
onDurationChanged: {
|
||||
if (!player.resumed && player.startMs > 0 && duration > 0) {
|
||||
player.resumed = true;
|
||||
seek(player.startMs);
|
||||
}
|
||||
}
|
||||
onPositionChanged: {
|
||||
if (!player.resumeReached && position >= player.startMs - 15000) {
|
||||
player.resumeReached = true;
|
||||
player.maybeReportStart();
|
||||
}
|
||||
}
|
||||
onEnded: player.finish()
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 10000
|
||||
repeat: true
|
||||
running: player.started && !player.finished
|
||||
onTriggered: player.report("progress")
|
||||
}
|
||||
|
||||
// Messages au centre : chargement / erreur.
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width * 0.7
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text !== ""
|
||||
text: player.error !== "" ? player.error + "\nAppuyez sur Retour pour quitter."
|
||||
: video.playerState === "error" ? video.errorString + "\nAppuyez sur Retour pour quitter."
|
||||
: video.playerState === "loading" || video.playerState === "idle" ? "Chargement…" : ""
|
||||
color: player.error !== "" || video.playerState === "error" ? Theme.error : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
style: Text.Outline
|
||||
styleColor: "black"
|
||||
}
|
||||
|
||||
// Informations de lecture (masquées après 4 s, sauf en pause).
|
||||
Item {
|
||||
id: osd
|
||||
|
||||
property bool shown: true
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: shown || video.playerState === "paused" ? 1 : 0
|
||||
|
||||
Behavior on opacity { NumberAnimation { duration: 200 } }
|
||||
|
||||
Rectangle {
|
||||
anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
|
||||
height: 170
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0; color: "transparent" }
|
||||
GradientStop { position: 1; color: "#E0000000" }
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
margins: Theme.pageMargin
|
||||
}
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: player.title
|
||||
elide: Text.ElideRight
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontTitle - 6
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 6
|
||||
radius: 3
|
||||
color: "#55FFFFFF"
|
||||
|
||||
Rectangle {
|
||||
width: video.duration > 0 ? parent.width * Math.min(1, video.position / video.duration) : 0
|
||||
height: parent.height
|
||||
radius: 3
|
||||
color: Theme.accent
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: stateText.implicitHeight
|
||||
|
||||
Text {
|
||||
id: stateText
|
||||
text: video.playerState === "paused" ? "Pause"
|
||||
: video.playerState === "playing" ? "Lecture"
|
||||
: video.playerState === "loading" ? "Chargement…" : ""
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSmall
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
text: Format.clock(video.position) + " / " + Format.clock(video.duration)
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: osdTimer
|
||||
interval: 4000
|
||||
onTriggered: osd.shown = false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Épisodes d'une saison ; OK ouvre la fiche de l'épisode.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string seriesId: ""
|
||||
property string seasonId: ""
|
||||
property string seasonName: ""
|
||||
property string seriesName: ""
|
||||
property var episodes: []
|
||||
property bool loading: true
|
||||
property string error: ""
|
||||
|
||||
fullscreen: true
|
||||
title: seriesName
|
||||
subtitle: seasonName
|
||||
initialFocus: list
|
||||
|
||||
Component.onCompleted: {
|
||||
page.session.loadEpisodes(seriesId, seasonId, function (err, items) {
|
||||
page.loading = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.episodes = items;
|
||||
list.forceActiveFocus();
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
ListView {
|
||||
id: list
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
focus: true
|
||||
spacing: Theme.spacingS
|
||||
model: page.episodes
|
||||
|
||||
delegate: Rectangle {
|
||||
id: row
|
||||
|
||||
readonly property bool highlighted: ListView.isCurrentItem && list.activeFocus
|
||||
|
||||
width: list.width
|
||||
height: 150
|
||||
radius: Theme.radius
|
||||
color: highlighted ? Theme.focusBackground : "transparent"
|
||||
|
||||
MediaCard {
|
||||
id: thumb
|
||||
anchors { left: parent.left; leftMargin: Theme.spacingS; verticalCenter: parent.verticalCenter }
|
||||
width: 240
|
||||
height: 135
|
||||
imageHeight: 135
|
||||
showText: false
|
||||
imageSource: page.session ? page.session.thumbUrl(modelData) : ""
|
||||
progress: Format.progress(modelData)
|
||||
played: modelData.played
|
||||
title: modelData.name
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors {
|
||||
left: thumb.right
|
||||
leftMargin: Theme.spacingL
|
||||
right: parent.right
|
||||
rightMargin: Theme.spacingM
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
spacing: 4
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: modelData.name
|
||||
elide: Text.ElideRight
|
||||
color: row.highlighted ? Theme.textOnFocus : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
text: "Épisode " + modelData.indexNumber
|
||||
+ (modelData.runtimeTicks ? " · " + Format.runtime(modelData.runtimeTicks) : "")
|
||||
color: row.highlighted ? Theme.textOnFocusMuted : Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: modelData.overview
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 3
|
||||
elide: Text.ElideRight
|
||||
color: row.highlighted ? Theme.textOnFocusMuted : Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
list.currentIndex = index;
|
||||
page.navigator.openItem(modelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.navigator.openItem(page.episodes[currentIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: text !== ""
|
||||
text: page.loading ? "Chargement…"
|
||||
: page.error !== "" ? page.error
|
||||
: page.episodes.length === 0 ? "Aucun épisode." : ""
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Jellyfin",
|
||||
"identifier": "com.stilobique.jellyfin",
|
||||
"version": "0.1.0",
|
||||
"description": "Jellyfin for Freebox",
|
||||
"icon": "icon.png",
|
||||
"capabilities": {
|
||||
|
||||
@@ -36,3 +36,23 @@ En mode développement, la box n'enregistre aucune donnée de l'application. Pou
|
||||
- `--user <nom>[:<mot de passe>]` (répétable) : le compte apparaît sur « Qui regarde ? », même si le serveur masque ses comptes. Avec un mot de passe, la connexion se fait en un clic ; sans, l'écran de connexion s'ouvre avec le nom pré-rempli. Le mot de passe n'apparaît pas dans les logs, mais il transite en clair sur le réseau local.
|
||||
|
||||
Le script sert les fichiers du projet au Player et affiche les logs de l'application. Il doit rester ouvert pendant le test (Ctrl+C pour arrêter).
|
||||
|
||||
## Publier sur le FreeStore
|
||||
```bash
|
||||
tools/package.py # crée dist/com.stilobique.jellyfin-<version>.tar.gz
|
||||
```
|
||||
|
||||
Pour une nouvelle version, modifier `version` dans `manifest.json` **et** `clientVersion` dans `Core/Session.qml` (le script refuse de créer le paquet si elles diffèrent).
|
||||
|
||||
Le script reproduit « Make FreeStore Package » du plugin QtCreator : il vérifie `manifest.json` et la syntaxe QML/JS (`qmllint`), puis crée l'archive à téléverser sur la console [FreeFactory](http://factory.free.fr) (compte développeur requis, validation par Free avant publication).
|
||||
|
||||
## Intégration continue
|
||||
Le workflow Gitea Actions `.gitea/workflows/ci.yml` :
|
||||
- à chaque push / pull request : vérifie le manifest et la syntaxe QML/JS, charge l'application en HTTP comme le Player (`tools/check-load.sh`) et publie le paquet en artefact ;
|
||||
- sur un tag `vX.Y.Z` (égal à la version du manifest) : crée une release Gitea avec le paquet FreeStore en pièce jointe.
|
||||
|
||||
```bash
|
||||
git tag v0.1.0 && git push origin v0.1.0
|
||||
```
|
||||
|
||||
Le téléversement sur la console FreeFactory reste manuel.
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
# Charge l'application comme le fait le Freebox Player (fichiers servis en HTTP) et échoue
|
||||
# si Qt signale une erreur ou un avertissement venant de l'app.
|
||||
# En HTTP, Qt ne peut pas lister les dossiers : c'est là qu'apparaissent les « X is not a type »
|
||||
# (qmldir manquant) ou « Cyclic dependency » (singletons), invisibles en lançant depuis le disque.
|
||||
#
|
||||
# Usage : tools/check-load.sh (LIBFBXQML=… pour un autre emplacement de libfbxqml)
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
LIBFBXQML="${LIBFBXQML:-$ROOT/../libfbxqml}"
|
||||
QMLSCENE="${QMLSCENE:-$(command -v qmlscene || echo /usr/lib/qt5/bin/qmlscene)}"
|
||||
DURATION="${DURATION:-6}"
|
||||
|
||||
if [ ! -d "$LIBFBXQML/fbx" ]; then
|
||||
echo "libfbxqml introuvable : git clone https://github.com/fbx/libfbxqml.git \"$LIBFBXQML\"" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
WORK="$(mktemp -d)"
|
||||
trap 'kill "$SERVER_PID" 2>/dev/null || true; rm -rf "$WORK"' EXIT
|
||||
|
||||
# Serveur HTTP sur un port libre (choisi par le système).
|
||||
python3 -I - "$ROOT" > "$WORK/port" <<'EOF' &
|
||||
import functools, http.server, sys
|
||||
class Quiet(http.server.SimpleHTTPRequestHandler):
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), functools.partial(Quiet, directory=sys.argv[1]))
|
||||
print(server.server_address[1], flush=True)
|
||||
server.serve_forever()
|
||||
EOF
|
||||
SERVER_PID=$!
|
||||
for _ in $(seq 50); do [ -s "$WORK/port" ] && break; sleep 0.1; done
|
||||
PORT="$(cat "$WORK/port")"
|
||||
|
||||
echo "Chargement de http://127.0.0.1:$PORT/Jellyfin.qml pendant ${DURATION} s…"
|
||||
# Rendu logiciel : la CI (conteneur) n'a pas d'OpenGL.
|
||||
mkdir -p "$WORK/runtime" && chmod 700 "$WORK/runtime"
|
||||
XDG_RUNTIME_DIR="$WORK/runtime" QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software \
|
||||
timeout "$DURATION" "$QMLSCENE" -I "$LIBFBXQML" \
|
||||
"http://127.0.0.1:$PORT/Jellyfin.qml" > "$WORK/output" 2>&1 || true
|
||||
|
||||
# Messages attendus hors de la box : Settings de libfbxqml (pas d'objet App sur PC).
|
||||
grep -v -e "/libfbxqml/" -e "^qml: Setting" -e "^qml: Getting settings failed" -e "^\s*$" \
|
||||
"$WORK/output" > "$WORK/problems" || true
|
||||
|
||||
if [ -s "$WORK/problems" ]; then
|
||||
echo "Échec : messages inattendus au chargement :" >&2
|
||||
cat "$WORK/problems" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "OK : chargement sans erreur."
|
||||
Executable
+150
@@ -0,0 +1,150 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fabrique le paquet FreeStore (.tar.gz) à téléverser sur la console FreeFactory.
|
||||
|
||||
Reproduit « Outils > Freebox SDK > Make FreeStore Package » du plugin QtCreator Freebox
|
||||
(github.com/fbx/freebox-qtcreator-plugin, src/freestorepackager.cc) :
|
||||
- fichiers inclus comme dans Jellyfin.fbxproject : QML, JS, images, polices, qmldir et
|
||||
manifest.json (tools/ est exclu : l'aperçu PC n'a rien à faire sur la box) ;
|
||||
- vérifications : manifest.json (identifiant, version identique à Session.clientVersion,
|
||||
points d'entrée existants), JSON valides,
|
||||
syntaxe QML/JS (qmllint, s'il est installé) ;
|
||||
- archive tar (format ustar, avec les entrées de dossiers) compressée en gzip.
|
||||
|
||||
Usage : tools/package.py [--output dist/paquet.tar.gz]
|
||||
"""
|
||||
import argparse
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
|
||||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Types de fichiers repris de Jellyfin.fbxproject (QmlFiles, JavaScriptFiles, ImageFiles, Files).
|
||||
EXTENSIONS = {".qml", ".js", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".bmp", ".webp",
|
||||
".ttf", ".otf", ".woff"}
|
||||
NAMES = {"qmldir", "manifest.json"}
|
||||
EXCLUDED_DIRS = {"tools", "dist"}
|
||||
|
||||
|
||||
def collect_files():
|
||||
files = []
|
||||
for root, dirs, names in os.walk(PROJECT_DIR):
|
||||
rel_root = os.path.relpath(root, PROJECT_DIR)
|
||||
# Dossiers cachés (.git, .idea…) et dossiers d'outillage exclus.
|
||||
dirs[:] = sorted(d for d in dirs if not d.startswith(".")
|
||||
and not (rel_root == "." and d in EXCLUDED_DIRS))
|
||||
for name in sorted(names):
|
||||
if name in NAMES or os.path.splitext(name)[1].lower() in EXTENSIONS:
|
||||
files.append(os.path.normpath(os.path.join(rel_root, name)))
|
||||
return files
|
||||
|
||||
|
||||
def check_manifest(files):
|
||||
"""Mêmes règles que fileformat/manifest.cc du plugin. Renvoie le manifest."""
|
||||
path = os.path.join(PROJECT_DIR, "manifest.json")
|
||||
if not os.path.exists(path):
|
||||
raise ValueError("manifest.json manquant")
|
||||
manifest = json.load(open(path, encoding="utf-8"))
|
||||
identifier = manifest.get("identifier")
|
||||
if not isinstance(identifier, str) or not re.fullmatch(r"\w+(\.\w+)+", identifier):
|
||||
raise ValueError("manifest.json : « identifier » absent ou invalide (forme attendue : a.b.c)")
|
||||
entry_points = manifest.get("entryPoints")
|
||||
if not isinstance(entry_points, dict) or not entry_points:
|
||||
raise ValueError("manifest.json : « entryPoints » absent ou invalide")
|
||||
defaults = 0
|
||||
for key, entry in entry_points.items():
|
||||
if not isinstance(entry, dict) or not isinstance(entry.get("file"), str):
|
||||
raise ValueError("manifest.json : entryPoints.%s.file doit être un fichier" % key)
|
||||
if not re.fullmatch(r"[/\w.+~-]+", entry["file"]):
|
||||
raise ValueError("manifest.json : caractères invalides dans entryPoints.%s.file" % key)
|
||||
if entry["file"] not in files:
|
||||
raise ValueError("manifest.json : entryPoints.%s.file « %s » absent du paquet" % (key, entry["file"]))
|
||||
if "uiFlavor" in entry and entry["uiFlavor"] not in ("multi", "classic"):
|
||||
raise ValueError("manifest.json : entryPoints.%s.uiFlavor doit valoir multi ou classic" % key)
|
||||
if entry.get("default") is True:
|
||||
defaults += 1
|
||||
if defaults > 1:
|
||||
raise ValueError("manifest.json : un seul point d'entrée peut avoir « default »: true")
|
||||
version = manifest.get("version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"\d+\.\d+\.\d+", version):
|
||||
raise ValueError("manifest.json : « version » absente ou invalide (forme attendue : 1.2.3)")
|
||||
# La version envoyée à Jellyfin (Session.clientVersion) doit rester la même.
|
||||
session = open(os.path.join(PROJECT_DIR, "Core", "Session.qml"), encoding="utf-8").read()
|
||||
client = re.search(r'clientVersion:\s*"([^"]*)"', session)
|
||||
if not client or client.group(1) != version:
|
||||
raise ValueError("version du manifest (%s) différente de Session.clientVersion (%s)"
|
||||
% (version, client.group(1) if client else "introuvable"))
|
||||
icon = manifest.get("icon")
|
||||
if icon and icon not in files:
|
||||
raise ValueError("manifest.json : icône « %s » absente du paquet" % icon)
|
||||
return manifest
|
||||
|
||||
|
||||
def check_sources(files):
|
||||
for name in files:
|
||||
if name.endswith(".json"):
|
||||
json.load(open(os.path.join(PROJECT_DIR, name), encoding="utf-8"))
|
||||
qmllint = shutil.which("qmllint")
|
||||
if not qmllint:
|
||||
print("Attention : qmllint introuvable, syntaxe QML/JS non vérifiée.")
|
||||
return
|
||||
sources = [os.path.join(PROJECT_DIR, f) for f in files if f.endswith((".qml", ".js"))]
|
||||
result = subprocess.run([qmllint] + sources, capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise ValueError("erreurs de syntaxe QML/JS :\n" + (result.stdout + result.stderr).strip())
|
||||
|
||||
|
||||
def build_archive(files, output):
|
||||
def info(name, is_dir, size=0):
|
||||
entry = tarfile.TarInfo(name + ("/" if is_dir else ""))
|
||||
entry.type = tarfile.DIRTYPE if is_dir else tarfile.REGTYPE
|
||||
entry.mode = 0o755 if is_dir else 0o644
|
||||
entry.size = size
|
||||
entry.mtime = int(time.time())
|
||||
entry.uid = entry.gid = 0
|
||||
entry.uname = entry.gname = ""
|
||||
return entry
|
||||
|
||||
os.makedirs(os.path.dirname(os.path.abspath(output)), exist_ok=True)
|
||||
seen_dirs = set()
|
||||
with tarfile.open(output, "w:gz", format=tarfile.USTAR_FORMAT) as archive:
|
||||
for name in files:
|
||||
# Entrées de dossiers (comme le plugin), du parent vers l'enfant.
|
||||
parts = name.split(os.sep)[:-1]
|
||||
for depth in range(1, len(parts) + 1):
|
||||
directory = "/".join(parts[:depth])
|
||||
if directory not in seen_dirs:
|
||||
seen_dirs.add(directory)
|
||||
archive.addfile(info(directory, True))
|
||||
data = open(os.path.join(PROJECT_DIR, name), "rb").read()
|
||||
archive.addfile(info(name.replace(os.sep, "/"), False, len(data)), io.BytesIO(data))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--output", help="archive à créer (défaut : dist/<identifier>-<version>.tar.gz)")
|
||||
args = parser.parse_args()
|
||||
|
||||
files = collect_files()
|
||||
try:
|
||||
manifest = check_manifest(files)
|
||||
check_sources(files)
|
||||
except (ValueError, json.JSONDecodeError) as error:
|
||||
sys.exit("Paquet non créé : %s" % error)
|
||||
|
||||
output = args.output or os.path.join(
|
||||
PROJECT_DIR, "dist", "%s-%s.tar.gz" % (manifest["identifier"], manifest["version"]))
|
||||
build_archive(files, output)
|
||||
print("Paquet créé : %s — version %s (%d fichiers, %.1f Ko)" % (
|
||||
os.path.relpath(output, os.getcwd()), manifest["version"], len(files), os.path.getsize(output) / 1024))
|
||||
print("À téléverser sur la console FreeFactory (http://factory.free.fr).")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user