[Feature]: Android app: watch and listen together, deep links

Ouverte
#48 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Une pull request liée a déjà été fusionnée.

  • #59 par @PhrolovaMoe — fusionnée

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
20/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
android, react-native, typescript

Piste de recherche

Read epic #40 and the prerequisite issues #45 and #46 first; inspect the named web entry points web/src/routes/together.$code.tsx, player/Room.tsx, player/sync.ts, routes/listen.$code.tsx and music/listen.ts. The issue also names packages/shared as the destination for shared protocol logic. Done means implementing the listed Android room, link, guest and notification flows while preserving web behavior and meeting the sync, queue, sharing and Live Update acceptance criteria; a linked merged PR indicates work has already proceeded.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

enhancement

[!NOTE]
This issue was written by Claude (Claude Opus 5.5) from a planning session with @PhrolovaMoe. Part of #40, builds on #45 and #46. Read the epic first.

Area

Streaming / playback

Problem

Watch together (web/src/routes/together.$code.tsx, player/Room.tsx, player/sync.ts) and listen together (routes/listen.$code.tsx, music/listen.ts) are core features. Rooms are joined through links, often by people who aren't signed in (public rooms allow named guests). The app has to speak both protocols, open room links, and let guests in.

Proposed solution
Protocols (facts; no server changes)
  • Watch: a WebSocket at /api/together/{code}/ws?name=<guest name>. Listen: /api/listen/{code}/ws?name=…. Both are plain JSON, not GraphQL.
  • The server authenticates the upgrade from the Authorization: Bearer header (or cookie). Guests are allowed into public rooms with a name (src/api/together.rs:27-39).
  • Messages are as in sync.ts (Outgoing: ping, play/pause/seek, rate, status, tracks, media, name, settings, invite, end) and listen.ts (plus skip, queue, add, remove, move).
  • The welcome message carries serverTime for clock sync.
  • Room media goes through room-scoped routes (/api/together/{code}/media/{id}/…, /api/listen/{code}/tracks/{id}/…, room avatars and art), which work for guests.
Sharing code with web
  • Move the platform-independent parts of sync.ts and listen.ts into packages/shared, and make web use them too:
    • message types
    • clock-offset estimation from the quickest recent round trips
    • the snapshot model
    • reconnect/backoff
    • the drift-correction rules
  • Inject the WebSocket constructor, the clock (performance.timeOrigin + performance.now() on web, a monotonic clock on Android), and media control.
  • React Native's WebSocket accepts headers on Android (new WebSocket(url, undefined, { headers })). Use it for the Bearer token.
  • Web behaviour must not change.
Watching together
  • The #45 player screen with the web Room.tsx features:
    • participants with avatars and status
    • control mode (everyone/host), wait-for-all, public toggle
    • invite users (invite), copy/share the link, end the room
    • RoomNotices, tap-to-join, and the room's own track selection (tracks)
  • Phone presentation: a participants pill in the player's top bar, which opens a bottom sheet with people, settings and invite. Join/leave notices are toasts over the video.
  • Sharing uses the Android share sheet with the room's https web URL (it works for people without the app).
  • Drift correction drives the #45 module API (seek, setRate, play/pause) as sync.ts drives <video> today.
Listening together
  • A room screen like listen.$code.tsx: Now Playing-style art, shared queue (add/remove/move with the reorder haptics), participants, invite, settings, and the ambient tint.
  • Playback goes through the #46 engine through followRemote (shared in #46). The mini-player shows the room while you're in it.
Live Update for sessions
  • While in a room, post a promoted ongoing notification (Android 16 Live Update; a normal ongoing notification on 14/15):
    • "Watching together · 3 people" or "Listening together · 3 people", with the host's name
    • tap to return to the room, and a "Leave" action
  • Update it when people join or leave. Remove it when you leave or the room ends.
  • Media playback keeps its media notification as well.
Deep links
  1. Custom scheme, handled with Expo Router linking:
    • tinystream://<host[:port]>/together/<code>
    • tinystream://<host[:port]>/listen/<code>
    • tinystream://<host[:port]>/title/<id>, /album/<id>, /artist/<id>, /playlist/<id>, /c/<code> (public clip pages, #49)
    • The scheme means https. Add ?insecure=1 for http servers.
  2. Share to the app: an intent filter for ACTION_SEND with text/plain. If the shared text contains a URL whose path matches one of the routes above (the web UI's paths are the same), handle it as the custom-scheme link for that origin. This is how "open a tinystream link in the app" works for any self-hosted domain. Verified https App Links can't be used, because they need every domain declared in the APK at build time.
  3. Web UI change: on Android browsers (UA check), the web's together, listen and public clip pages show a small dismissible "Open in the app" banner linking to the matching tinystream:// URL. Dismissal is remembered in localStorage.

Resolving a link:

  • If the link's origin matches a saved server, switch to it (#42 rules), then:
    • signed in → open the screen
    • room link and signed out → the guest flow
    • anything else and signed out → sign in, then continue
  • If it's an unknown server:
    • room links → the guest flow
    • other links → offer "Add this server" (#42 connect flow pre-filled), then continue

Guest flow:

  • A sheet: "Join room title on server as a guest". A name field, prefilled with the last guest name used on this device, plus Join.
  • Guests connect without a token and aren't added to the saved server list (offer "Add this server" after leaving).
  • While joined as a guest, the rest of the app keeps showing the user's own active server. The room screen is modal over it.
Acceptance criteria
  • Phone and web in the same watch room stay in sync (play, pause, seek, rate, and the correction after a stall), both as a signed-in user and as a guest.
  • The same for listen rooms, including queue edits from either side.
  • Sharing a room link from the browser to the app joins it. adb shell am start -d "tinystream://host/together/CODE" joins. An unknown server leads to the guest flow.
  • The Live Update shows the participant count and Leave works.
  • The web "Open in the app" banner appears on Android only.
Langage dominant
TypeScript
Étoiles
4
Forks
1
Merge moyen
4 h 49 min
PR mergées (30 j)
5

Préparer son environnement

  • Fournit un Dockerfile ou un fichier Docker Compose
  • Aucun modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de tinystream-dev/tinystream

Toutes les issues de tinystream-dev/tinystream

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.