zijunchiang eadc2d4de1 V1.5.0: 修复"公放切歌失效"——上一版清空歌曲缓存把公放曲库删了(新设备回归)
现象: 新设备公放时按「切歌」没有任何反应。

根因(我上一版引入的回归):
- 1.4.10 为了让"被当成歌曲缓存下来的广告视频"消失,在启动时做了一次
  **整目录清理**(删 cloud-song 下所有 .ts/.ls/.mp4/.mkv)。
- 但 MuseDatabase.songDirectories() **只有 cloudSongsDir 一个目录**,
  SongOkDownloadManager.getLocalFile() 也落在那里 —— 那等于**把公放曲库整个删掉**。
- 后果链: 库空 → playRandomLocalSong() 里 allLocalSongs 为空 →
  RandomPlayQueue.next() 返回 null → 状态栏"本地暂无可播放歌曲"、currentSong 保持 null
  → 按「切歌」时 advancePlayback 落进「取消随机续播、进入空闲态」分支 → 按钮无反应。
  (RandomPlayQueue.next 本身有"只剩一首也能播"的兜底,队列逻辑没问题。)

修复:
- 删除整目录清理,改为 purgeInjectedAdDuplicatesOnce(): **只删能证明是注入广告的文件** ——
  广告对每首歌下发同一个视频,特征是"多首不同歌曲的本地文件内容完全相同"
  (按文件大小 + 头部 4MB 指纹分组,只清理 size>=2 的完全相同组)。
  正常歌曲内容各不相同,绝不会被误删;公放曲库得以保留。

同时按用户要求,复查"老设备适配期间改动对新设备的影响",另修正两处:
- SongApiClient.getSongDownloadUrl 的主线程分支: 1.4.7 起会先走 resolveNatively()
  (最多 7 个源 × 8 秒超时的阻塞网络请求)—— 一旦有主线程调用者就会卡死 UI 到 ANR。
  现在主线程只做本地 DB 兜底,网络取址一律留在后台线程。
- KtvJsBridge 裸 Socket 的 HTTPS 分支: 1.4.6 改用了无参 createSocket(),拿到的 SSLSocket
  **不带主机名**(影响 SNI 与证书主机名校验,共享 CDN/反代多证书时会握手失败)。
  改为先 connect 普通 socket(保留显式连接超时)再 createSocket(plain, host, port, true)。
- buildDownloadUrl 的文件名比对只在点歌编号"可信"时启用: 只有从 song.filename 推出的编号才
  参与比对;song.id 可能是数据库主键,拿它比对会误杀正常地址(真源被判"文件名不符")。
  (另已实测 7 个源: 可用的 5 个真源 URL 文件名全部严格等于点歌编号,规则不会误杀。)

顺带记录用户给出的版本号约定(已写入 AGENTS.md):
versionName = <major>.<minor>.<patch>,patch 0~10、minor 1~10;
1.4.10 之后是 1.5.0,1.10.1 之后是 2.1.0;versionCode 始终 +1。

版本 1.4.10(30) → 1.5.0(31);签名证书不变。测试 8 例全通过。
2026-09-26 21:25:37 +08:00

Maidong KTV Logo

Maidong KTV

A local karaoke application for Android TV and landscape song-selection devices

Remote Control · Song Discovery · Request Queue · Download Management · Stable Playback

Core Features

  • Full TV remote navigation with directional keys, confirmation, back, and long-press actions.
  • Consistent focus feedback for buttons, lists, cards, switches, and dialogs.
  • Home entries for charts, song titles, singers, frequently played songs, favorites, categories, and local songs.
  • Online and local search with language filters, paging, and initial-letter keyboard input.
  • Singer browsing with portrait tags and singer-specific song lists.
  • Song ordering, batch ordering, queue prioritization, favorites, and file management.
  • Real-time synchronization across queued, played, and downloaded song lists.
  • New requests join the end of the queue without interrupting the current requested song.
  • Automatic playback when requested songs are available, including smooth transitions from public playback.

Playback

  • IJK-based playback for local and downloaded songs.
  • Continuous playback while navigating between pages or switching between windowed and full-screen modes.
  • Play, pause, skip, replay, progress display, and seeking controls.
  • Original-vocal and accompaniment switching without changing the current play or pause state.
  • Synchronized playback state across windowed controls, full-screen controls, and status overlays.
  • Song title overlays, temporary mode prompts, and persistent pause indicators.
  • Video ratio, automatic full screen, audio-video synchronization, and public playback settings.
  • Maximum song volume and configurable original-vocal and accompaniment behavior.

Downloads And Data

  • Background downloads with progress, resume support, and automatic retry.
  • Automatic cleanup and retry after download or decryption failures.
  • Recognition, counting, and playback of downloaded local songs.
  • Segmented database download, verification, merge, and atomic update.
  • Directory creation, database scanning, and download startup only after storage permission is granted.
  • Local disk and USB song scanning, reserved storage settings, and automatic cleanup.
  • Unified Maidong KTV data storage to avoid conflicts with other applications.

Settings

  • Data settings for library updates, local scanning, reserved space, automatic cleanup, and database maintenance.
  • Playback settings for public playback, automatic full screen, video ratio, synchronization, and title overlays.
  • Sound settings for volume behavior, maximum song volume, original vocals, and accompaniment.
  • Interface settings for language, floating controls, carousel content, and song title overlays.
  • Dialog selections remain temporary until confirmed and provide clear remote-control focus feedback.

Interface And Interaction

  • Landscape TV layout optimized for long-distance viewing.
  • Consistent state and meaning across top, windowed, and full-screen playback controls.
  • Stable focus during list refreshes, paging, tab changes, and song ordering.
  • Focus changes color only and preserves each control's original dimensions, corners, and layout.
  • A consistent circular Maidong logo across the home screen, player, and application information.

Project Notice

This repository: https://gitea.kasugano.cn/zijunchiang/maidong-ktv

UI/feature framework credit: https://gitee.com/yangyachao-X/maidong-ktv

This repository reworks the upstream "Maidong KTV" UI and feature framework, and the core/data layer was rewritten with DSH (DeepSeek Harness): library sync, song-source integration, device auth, risk-control handling, remote logging, and ad blocking are all new implementations.

Highlights of the reworked data layer:

  • Library: synced exclusively from the official Muse service (mconn.cherryonline.cn mls-api/v1/sqlite/sync); the code host carries source only, no database files.
  • Song source: w.w345.my (i.php token → do.php playback URL) with fixed device identity and reproduced signing; ad/mismatched resources (e.g. wb66.cn/.../719.ts) are blocked and retried.
  • JS hot-update: app/src/main/assets/mobile/ktv_api.js, requires the KTV_BRIDGE_API: 7 marker.

Building

Requirements: JDK 17, Android SDK (compileSdk 35, minSdk 21, targetSdk 25), Gradle wrapper 8.13 (bundled).

cd maidong-ktv
export JAVA_HOME=/path/to/jdk-17
export ANDROID_HOME=/path/to/android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
./gradlew assembleRelease

The release signing config in app/build.gradle expects ../../ktv_keystore.jks (one level above the repo root) with alias ktv / password 123456; adjust paths or use signingConfigs.debug for a quick unsigned build. Output: app/build/outputs/apk/release/app-release.apk (dual ABI: armeabi-v7a + arm64-v8a). Install with adb install -r <apk>.

For non-commercial learning purposes only. Respect upstream copyright and song licensing.

S
Description
麦动KTV Android 项目源码(DSH 重写内核与数据源)
Readme
18 MiB
2026-10-18 11:41:38 +08:00
Languages
Kotlin 50.7%
Python 41.5%
Java 4.6%
JavaScript 2.7%
HTML 0.3%
Other 0.2%