我正在尝试使用 ExoPlayer 播放 AAC 流。我在使用内置的 MediaPlayer 时遇到了同样的问题:在 KitCat 上启动需要 15 到 20 秒(可能在其他版本上也会发生同样的情况,但现在没有任何要测试的东西)。
在 ExoPlayer 上,我能够获得一些关于后台发生的事情的信息。
流程卡住MediaExtractor.getDataSource()
,FrameworkSampleDataSource
方法prepare
extractor = new MediaExtractor();
extractor.setDataSource(context, uri, headers);
日志中提到了有关readAt
方法超时的内容
01-12 12:07:03.458 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ mDisconnectAtHighwatermark = 0, cacheConfig is NULL(1)
01-12 12:07:03.463 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:03.463 4537-4615/com.example.claudio.exopla I/ChromiumHTTPDataSource﹕ readAt offset =0 , mCurrentOffset = 0 size = 65536
01-12 12:07:04.298 4537-4615/com.example.claudio.exopla D/HTTPBase﹕ [1] Network BandWidth = 0 Kbps
01-12 12:07:04.298 4537-4615/com.example.claudio.exopla D/NuCachedSource2﹕ Remaining (64K), HighWaterThreshold (20480)
01-12 12:07:04.298 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:04.298 4537-4615/com.example.claudio.exopla I/ChromiumHTTPDataSource﹕ readAt offset =65536 , mCurrentOffset = 65536 size = 65536
01-12 12:07:04.298 4537-4584/com.example.claudio.exopla V/ChromiumHTTPDataSource﹕ mContentSize is undefined or network might be disconnected
01-12 12:07:04.298 4537-4584/com.example.claudio.exopla V/ChromiumHTTPDataSource﹕ mContentSize is undefined or network might be disconnected
01-12 12:07:04.323 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:06.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:06.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:06.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:08.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:08.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:08.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:10.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:10.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:10.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:12.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:12.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:12.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:14.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:14.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:14.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:16.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:16.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:16.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:18.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:18.328 4537-4584/com.example.claudio.exopla E/NuCachedSource2﹕ readAt:Timeout ( player case )
01-12 12:07:18.328 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: mIsMetadataRetriever == 0
01-12 12:07:18.413 4537-4615/com.example.claudio.exopla D/HTTPBase﹕ [2] Network BandWidth = 70 Kbps
01-12 12:07:18.413 4537-4615/com.example.claudio.exopla D/NuCachedSource2﹕ Remaining (127K), HighWaterThreshold (20480)
01-12 12:07:18.413 4537-4615/com.example.claudio.exopla D/NuCachedSource2﹕ readInternal - late!!!
01-12 12:07:18.418 4537-4584/com.example.claudio.exopla I/NuCachedSource2﹕ readAt: waiting end ( player case )
01-12 12:07:18.418 4537-4615/com.example.claudio.exopla I/ChromiumHTTPDataSource﹕ readAt offset =131072 , mCurrentOffset = 131072 size = 65536
01-12 12:07:18.423 4537-4584/com.example.claudio.exopla E/tmiMPEG2TSExtractor﹕ SnifftmiMPEG2TS @LINE=1372
我想这可能与缓冲有关,因为 MediaPlayer 有类似的问题。这只发生在真实设备上,模拟器会立即启动。