zijunchiang b40a2bdf9b V1.5.1(重发): 修复"切歌→公放"在老设备(极米 H1S)上卡死
现象: 点歌列表切歌到公放列表,新设备正常,老设备(极米 H1S)卡死。

排查出三个叠加原因,且都是"新设备看不出来、老设备致命"的类型:

1. 切歌任务排在长任务后面(线程池饿死)
   切歌用的是 MainActivity.io(固定 4 线程),而"点歌即下即播"(streamDownloadAndPlay)
   这类几十秒的长任务也在同一个池里。H1S 网速慢,并发点几首歌就把池占满,
   切歌任务一直排队 → 旧歌播完后没声、按什么都没反应。
   修复: 切歌/随机续播改用专用单线程 randomPlayExecutor(守护线程),与下载彻底隔离。

2. 切歌时现扫目录找候选(慢 + 可能永久阻塞)
   候选来自 localSongInventory() + library.scanLocal():
   - SongFileValidator 对每个文件在头尾各读约 4.3MB 做 TS 校验;
   - scanLocal() 会遍历 /storage 各挂载点,老 ROM 上的失效挂载点会让 File.listFiles() 永久阻塞。
   修复: 启动时后台预热候选缓存(独立守护线程 + scanWithTimeout 4s 超时保护),
   下载完成即时补进缓存;切歌直接读缓存(零 I/O),缓存未就绪时只走安全的库存查询。

3. 主线程上做深度文件校验(直接 ANR)
   Song.hasLocalFile() 内部就是 SongFileValidator.inspect(头尾各读 4.3MB),
   却被用在 play()、播放错误回调、switchToLocalPlayback,
   以及**逐行渲染**的 songRowState() 里 —— 而 advancePlayback 恰好会调 renderQueue()。
   H1S 的慢存储上,队列每行一次深度校验就是数秒卡顿。
   修复: 播放/渲染路径统一改用廉价检查 hasPlayableLocalFile()(只看存在与大小),
   深度校验只保留在后台(localSongInventory() / isDownloaded())。

顺带修掉一个自己踩的坑: Kotlin 块注释会嵌套,KDoc 里写 /storage/* 会开启嵌套注释导致
KDoc 不闭合、后续代码被吞(报错为 Unclosed comment + Missing '}')。已改写为不含 /* 的说法。

版本名保持 1.5.1(按用户要求撤回后重发同一版本),versionCode 32 → 33(保证可覆盖升级)。
签名证书不变。测试 8 例全通过。
2026-09-26 22:33:36 +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%