Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mức tiêu thụ pin do phát nội dung nghe nhìn có quan trọng không?
Việc tránh tiêu thụ pin không cần thiết là một khía cạnh quan trọng trong quá trình phát triển một ứng dụng Android hiệu quả. Việc phát nội dung nghe nhìn có thể là nguyên nhân chính gây hao pin, tuy nhiên, tầm quan trọng của việc này đối với một ứng dụng cụ thể phụ thuộc nhiều vào các mẫu sử dụng của ứng dụng đó. Nếu một ứng dụng chỉ dùng để phát một lượng nhỏ nội dung nghe nhìn mỗi ngày, thì mức tiêu thụ pin tương ứng sẽ chỉ chiếm một tỷ lệ nhỏ trong tổng mức tiêu thụ pin của thiết bị. Trong những trường hợp như vậy, bạn nên ưu tiên bộ tính năng và độ tin cậy hơn là tối ưu hoá pin khi chọn trình phát để sử dụng. Mặt khác, nếu một ứng dụng thường được dùng để phát một lượng lớn nội dung nghe nhìn mỗi ngày, thì bạn nên cân nhắc nhiều hơn đến việc tối ưu hoá mức tiêu thụ pin khi chọn giữa một số tuỳ chọn khả thi.
ExoPlayer tiết kiệm pin như thế nào?
Do bản chất đa dạng của hệ sinh thái nội dung nghe nhìn và thiết bị Android, nên rất khó đưa ra tuyên bố có thể áp dụng rộng rãi về mức tiêu thụ pin của ExoPlayer. Hiệu suất sẽ khác nhau tuỳ theo phần cứng, phiên bản Android và nội dung đa phương tiện đang phát. Do đó, bạn chỉ nên coi thông tin sau đây là thông tin tham khảo.
Phát lại video
Đối với việc phát video, màn hình và quá trình giải mã luồng video chiếm phần lớn năng lượng tiêu thụ trong khi phát.
Việc chọn giữa SurfaceView và TextureView cho đầu ra có thể ảnh hưởng đáng kể đến mức tiêu thụ điện năng. SurfaceView tiết kiệm điện năng hơn, trong khi TextureView làm tăng tổng mức tiêu thụ điện năng trong khi phát video lên tới 30% trên một số thiết bị. Do đó, bạn nên ưu tiên sử dụng SurfaceView nếu có thể. Đọc thêm về cách chọn giữa SurfaceView và TextureViewtrên trang Surface.
Trên một số TV, việc sử dụng tính năng chuyển tiếp video có thể cung cấp đường dẫn hiệu quả hơn để phát video có độ phân giải cao khi đường dẫn phát thông thường không đủ hiệu suất để phát mượt mà.
Phát âm thanh
Đối với các bản phát âm thanh ngắn hoặc phát khi màn hình đang bật, âm thanh không ảnh hưởng đáng kể đến nguồn pin.
Đối với các bản phát dài khi màn hình tắt, bạn có thể tiết kiệm pin bằng cách sử dụng chế độ giảm tải âm thanh của ExoPlayer. Hãy xem track selection guide để biết thêm thông tin chi tiết về cách bật tính năng này.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Battery consumption\n\nHow important is battery consumption due to media playback?\n-----------------------------------------------------------\n\nAvoiding unnecessary battery consumption is an important aspect of developing a\nperformant Android app. Media playback can be a major cause of battery drain,\nhowever its importance for a particular app heavily depends on its usage\npatterns. If an app is only used to play small amounts of media each day, then\nthe corresponding battery consumption will only be a small percentage of the\ntotal consumption of the device. In such cases, it makes sense to prioritize\nfeature set and reliability over optimizing for battery when selecting which\nplayer to use. On the other hand, if an app is often used to play large amounts\nof media each day, then optimizing for battery consumption should be weighted\nmore heavily when choosing between a number of viable options.\n\nHow power efficient is ExoPlayer?\n---------------------------------\n\nThe diverse nature of the Android device and media content ecosystems means that\nit's difficult to make widely applicable statements about ExoPlayer's battery\nconsumption. Performance varies by hardware, Android version, and the media\nbeing played. Hence the following information should be treated as guidance\nonly.\n\n### Video playback\n\nFor video playback, the display and decoding of the video stream account for\nmost of the power consumed during playback.\n\nChoosing between `SurfaceView` and `TextureView` for output can have a\nsignificant impact on power consumption. `SurfaceView` is more power efficient,\nwith `TextureView` increasing total power draw during video playback by as much\nas 30% on some devices. `SurfaceView` should therefore be preferred where\npossible. Read more about choosing between `SurfaceView` and `TextureView`\n[on the Surface page](/media/media3/ui/surface).\n\nOn some TVs, using [video tunneling](/media/media3/exoplayer/track-selection#tunneling) may provide a more efficient path for\nhigh-resolution video playback where the regular playback path is not performant\nenough for smooth playback.\n| **Note:** Tunneling moves all video decoding and release timing to a dedicated hardware processor. However, be aware that the implementation is device-specific. Performance and reliability can vary greatly between devices. It's highly advisable to test your media streams on the specific TV devices where you intend to enable tunneling to verify it is reliable enough for your use case.\n\n### Audio playback\n\nFor short audio playbacks or playbacks when the screen is on, audio does not\nhave a significant impact on power.\n\nFor long playbacks with the screen off, it's possible to save power by using\nExoPlayer's audio offload mode. See the [`track selection guide`](/media/media3/exoplayer/track-selection#audioOffload) for more\ndetails on how to enable it.\n| **Note:** Audio offload allows audio processing to be offloaded from the CPU to a dedicated signal processor. Device and format support varies, so it's advisable to thoroughly test audio offload with your media on your target devices. Offload also limits the ability to apply audio effects, like speed changes and silence skipping."]]