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

Đang mở
#48 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Một pull request liên quan đã được merge.

  • #59 của @PhrolovaMoe — đã merge

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
20/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, react-native, typescript

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
4
Fork
1
Merge trung bình
4 giờ 49 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tinystream-dev/tinystream

Tất cả issue của tinystream-dev/tinystream

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.