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

未关闭
#48 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

已经有一个关联 PR 被合并了。

  • #59 来自 @PhrolovaMoe —— 已合并

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
android, react-native, typescript

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
TypeScript
星标
4
派生
1
平均合并
4 小时 49 分钟
30 天内合并 PR
5

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tinystream-dev/tinystream 的其他 Issue

查看 tinystream-dev/tinystream 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。