Files
shenlei 3e60bf1869 修复阅读器资源、朗读与持久化稳定性
阅读器在多会话朗读、加密 EPUB 资源、并发打开同一本书和多 UserDefaults 容器等场景下,存在旧异步结果覆盖新状态、锁屏控制串会话、大型明文资源被误拒绝、解压半成品被复用及标注跨容器混用的风险;同时高亮、书签、搜索和设置面板的空状态与自动化可访问性入口不完整。\n\n本次为朗读会话引入代次和当前 utterance 校验,远程控制改为仅响应当前会话并按自身 token 清理;加密资源 provider 先判定是否实际返回解密数据,明文大资源继续流式读取;解压缓存串行化以避免并发复用未完成目录。书签与高亮迁移至受保护文件,按 UserDefaults 容器隔离命名空间,保留标准容器旧文件兼容并确保新副本成功落盘后才删除历史数据。\n\n同步调整缓存淘汰、FoundationModels 弱链接、搜索/标注/设置面板交互与 UI 测试,并更新 Pod 生成配置及 API、风险文档。已执行 git diff --check 和 ReadViewDemo Debug Simulator 构建,结果为 BUILD SUCCEEDED。
2026-07-30 20:52:21 +09:00
..
2026-07-27 21:43:13 +08:00

RDSpeechReaderView

RDSpeechReaderView provides bounded, on-device text-to-speech playback for ReadViewSDK readers. It uses AVSpeechSynthesizer and does not upload book content or create exportable audio files.

Install

pod 'RDSpeechReaderView'
pod 'RDPDFReaderView/Speech'
pod 'RDEpubReaderView/Speech'

The host app must enable the Audio, AirPlay, and Picture in Picture background mode to continue reading after it enters the background.

Use with PDF

let provider = reader.makeSpeechContentProvider()
let speech = RDSpeechReaderController(contentProvider: provider)
try await speech.start()

The PDF adapter reads RDPDFReaderTextRun values supplied by the host or by PDFKit. Image-only PDFs require an OCR-backed provider before they can speak.

For automatic page navigation and temporary read-aloud highlighting, create a PDF session instead:

let session = reader.makeSpeechSession()
try await session.start(from: 0)

Use with EPUB

let session = reader.makeSpeechSession()
try await session.start()

EPUB/TXT 会话默认从当前阅读位置开始。文本重排 EPUB 与 TXT 会临时高亮当前朗读范围, 并且只在朗读跨页时定位;朗读位置使用 EPUB href 与 UTF-16 文本偏移,因此用户修改 字体或页面大小后仍可稳定恢复。