衡量性能
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在 Android 8.0(API 级别 26)及更高版本中,getMetrics()
方法可用于某些媒体类。它会返回一个包含配置和性能信息的 PersistableBundle
对象(表示为属性和值的对应关系)。可以为这些媒体类定义 getMetrics()
方法:
系统会为每个实例分别收集相关指标,并在实例的整个生命周期内保留这些指标。如果没有任何可用指标,则该方法会返回 null。返回的实际指标取决于类。
使用 ExoPlayer 进行分析
ExoPlayer 包含可帮助您收集和处理播放数据的工具。如需了解详情,请参阅开发者指南中的分析部分。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Measuring performance\n\nIn Android 8.0 (API level 26) and later, the `getMetrics()` method is available\nfor some media classes. It returns a\n[PersistableBundle](/reference/android/os/PersistableBundle)\nobject containing configuration\nand performance information, expressed as a map of attributes and values.\nThe `getMetrics()` method is defined for these media classes:\n\n- [MediaPlayer.getMetrics()](/reference/android/media/MediaPlayer#getMetrics())\n- [MediaRecorder.getMetrics()](/reference/android/media/MediaRecorder#getMetrics())\n- [MediaCodec.getMetrics()](/reference/android/media/MediaCodec#getMetrics())\n- [MediaExtractor.getMetrics()](/reference/android/media/MediaExtractor#getMetrics())\n\nMetrics are collected separately for each instance and persist for the\nlifetime of the instance. If no metrics are available the method returns\nnull. The actual metrics returned depend on the class.\n\nAnalytics with ExoPlayer\n------------------------\n\nExoPlayer includes tools to help you collect and process playback data. Learn\nmore in the developer guide for\n[analytics](/guide/topics/media/exoplayer/analytics)."]]