Logging debug
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Secara default, ExoPlayer hanya mencatat error. Untuk mencatat log peristiwa pemain, EventLogger
dapat digunakan. Pencatatan log tambahan yang
disediakan olehnya dapat membantu
memahami apa yang dilakukan pemutar, serta untuk proses debug pemutaran
masalah performa. EventLogger
mengimplementasikan AnalyticsListener
. Jadi, mendaftarkan instance
dengan ExoPlayer
itu mudah:
Kotlin
player.addAnalyticsListener(EventLogger())
Java
player.addAnalyticsListener(new EventLogger());
Cara termudah untuk mengamati log adalah menggunakan tab logcat Android Studio. Anda
dapat memilih aplikasi Anda sebagai proses yang dapat di-debug berdasarkan nama paket (
androidx.media3.demo.main
jika menggunakan aplikasi demo) dan memberi tahu logcat
untuk membuat log aplikasi tersebut saja dengan memilih tampilkan hanya aplikasi yang dipilih. Penting
memfilter lebih lanjut pencatatan log dengan
EventLogger|ExoPlayerImpl
, untuk mendapatkan logging dari EventLogger
dan
pada pemutar video Anda.
Alternatif untuk menggunakan tab logcat Android Studio adalah dengan menggunakan konsol. Contoh:
adb logcat EventLogger:* ExoPlayerImpl:* *:s
Class ExoPlayerImpl
mengirimkan dua baris penting tentang versi pemutar,
perangkat dan OS tempat aplikasi berjalan, dan modul ExoPlayer yang memiliki
telah dimuat:
ExoPlayerImpl: Init 59a18ab [AndroidXMedia3/1.0.0-rc02] [flame, Pixel 4, Google, 33]
ExoPlayerImpl: Release 59a18ab [AndroidXMedia3/1.0.0-rc02] [flame, Pixel 4, Google, 33] [media3.common, media3.datasource, media3.ui, media3.exoplayer, media3.decoder, media3.exoplayer.dash, media3.extractor]
Status pemutaran
Perubahan status pemutar dicatat dalam baris seperti ini:
EventLogger: playWhenReady [eventTime=0.00, mediaPos=0.00, window=0, true, USER_REQUEST]
EventLogger: state [eventTime=0.01, mediaPos=0.00, window=0, BUFFERING]
EventLogger: state [eventTime=0.93, mediaPos=0.00, window=0, period=0, READY]
EventLogger: isPlaying [eventTime=0.93, mediaPos=0.00, window=0, period=0, true]
EventLogger: playWhenReady [eventTime=9.40, mediaPos=8.40, window=0, period=0, false, USER_REQUEST]
EventLogger: isPlaying [eventTime=9.40, mediaPos=8.40, window=0, period=0, false]
EventLogger: playWhenReady [eventTime=10.40, mediaPos=8.40, window=0, period=0, true, USER_REQUEST]
EventLogger: isPlaying [eventTime=10.40, mediaPos=8.40, window=0, period=0, true]
EventLogger: state [eventTime=20.40, mediaPos=18.40, window=0, period=0, ENDED]
EventLogger: isPlaying [eventTime=20.40, mediaPos=18.40, window=0, period=0, false]
Dalam contoh ini, pemutaran dimulai 0,93 detik setelah pemutar disiapkan. Tujuan
pengguna menjeda pemutaran setelah 9,4 detik, dan melanjutkan pemutaran satu detik kemudian
10,4 detik. Pemutaran akan berakhir sepuluh detik kemudian pada detik ke-20,4. Hal yang umum
elemen di dalam tanda kurung siku adalah:
[eventTime=float]
: Waktu jam dinding sejak pembuatan pemain.
[mediaPos=float]
: Posisi pemutaran saat ini.
[window=int]
: Indeks jendela saat ini.
[period=int]
: Periode saat ini dalam periode tersebut.
Elemen akhir di setiap baris menunjukkan nilai status yang dilaporkan.
Informasi trek akan dicatat saat trek yang tersedia atau yang dipilih berubah. Ini
terjadi minimal sekali saat pemutaran dimulai. Contoh di bawah ini
menunjukkan jalur
logging untuk streaming adaptif:
EventLogger: tracks [eventTime=0.30, mediaPos=0.00, window=0, period=0,
EventLogger: group [
EventLogger: [X] Track:0, id=133, mimeType=video/avc, bitrate=261112, codecs=avc1.4d4015, res=426x240, fps=30.0, supported=YES
EventLogger: [X] Track:1, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0, supported=YES
EventLogger: [X] Track:2, id=135, mimeType=video/avc, bitrate=1204535, codecs=avc1.4d401f, res=854x480, fps=30.0, supported=YES
EventLogger: [X] Track:3, id=160, mimeType=video/avc, bitrate=112329, codecs=avc1.4d400c, res=256x144, fps=30.0, supported=YES
EventLogger: [ ] Track:4, id=136, mimeType=video/avc, bitrate=2400538, codecs=avc1.4d401f, res=1280x720, fps=30.0, supported=NO_EXCEEDS_CAPABILITIES
EventLogger: ]
EventLogger: group [
EventLogger: [ ] Track:0, id=139, mimeType=audio/mp4a-latm, bitrate=48582, codecs=mp4a.40.5, channels=2, sample_rate=22050, supported=YES
EventLogger: [X] Track:1, id=140, mimeType=audio/mp4a-latm, bitrate=127868, codecs=mp4a.40.2, channels=2, sample_rate=44100, supported=YES
EventLogger: ]
EventLogger: ]
Dalam contoh ini, pemutar telah memilih empat dari lima video yang tersedia
lagu. Trek video kelima tidak dipilih karena melebihi
kemampuan perangkat, seperti yang ditunjukkan oleh supported=NO_EXCEEDS_CAPABILITIES
.
Pemutar akan menyesuaikan antara trek video yang dipilih selama pemutaran. Kapan
pemain beradaptasi dari satu trek ke trek lainnya, itu dicatat dalam baris seperti ini
di bawah ini:
EventLogger: downstreamFormat [eventTime=3.64, mediaPos=3.00, window=0, period=0, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0]
Baris log ini menunjukkan bahwa pemutar beralih ke video beresolusi 640x360
tiga detik ke media.
Pemilihan decoder
Pada umumnya, ExoPlayer merender media menggunakan MediaCodec
yang diperoleh dari
platform dasar. Ketika decoder diinisialisasi, baris ini akan dicatat dalam log seperti
berikut ini:
EventLogger: videoDecoderInitialized [0.77, 0.00, window=0, period=0, video, OMX.qcom.video.decoder.avc]
EventLogger: audioDecoderInitialized [0.79, 0.00, window=0, period=0, audio, OMX.google.aac.decoder]
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Debug logging\n\nBy default, ExoPlayer only logs errors. To log player events, the `EventLogger`\nclass can be used. The additional logging it provides can be helpful for\nunderstanding what the player is doing, as well as for debugging playback\nissues. `EventLogger` implements `AnalyticsListener`, so registering an instance\nwith an `ExoPlayer` is easy: \n\n### Kotlin\n\n```kotlin\nplayer.addAnalyticsListener(EventLogger())\n```\n\n### Java\n\n```java\nplayer.addAnalyticsListener(new EventLogger());\n```\n\n\u003cbr /\u003e\n\nThe easiest way to observe the log is using Android Studio's [logcat tab](/studio/debug/am-logcat). You\ncan select your app as debuggable process by the package name (\n`androidx.media3.demo.main` if using the demo app) and tell the logcat\ntab to log only for that app by selecting **show only selected application** . It's\npossible to further filter the logging with the expression\n`EventLogger|ExoPlayerImpl`, to get only logging from `EventLogger` and the\nplayer itself.\n\nAn alternative to using Android Studio's logcat tab is to use the console. For\nexample: \n\n adb logcat EventLogger:* ExoPlayerImpl:* *:s\n\n### Player information\n\nThe `ExoPlayerImpl` class delivers two important lines about the player version,\nthe device and OS the app is running on and the modules of ExoPlayer that have\nbeen loaded: \n\n ExoPlayerImpl: Init 59a18ab [AndroidXMedia3/1.0.0-rc02] [flame, Pixel 4, Google, 33]\n ExoPlayerImpl: Release 59a18ab [AndroidXMedia3/1.0.0-rc02] [flame, Pixel 4, Google, 33] [media3.common, media3.datasource, media3.ui, media3.exoplayer, media3.decoder, media3.exoplayer.dash, media3.extractor]\n\n### Playback state\n\nPlayer state changes are logged in lines like these: \n\n EventLogger: playWhenReady [eventTime=0.00, mediaPos=0.00, window=0, true, USER_REQUEST]\n EventLogger: state [eventTime=0.01, mediaPos=0.00, window=0, BUFFERING]\n EventLogger: state [eventTime=0.93, mediaPos=0.00, window=0, period=0, READY]\n EventLogger: isPlaying [eventTime=0.93, mediaPos=0.00, window=0, period=0, true]\n EventLogger: playWhenReady [eventTime=9.40, mediaPos=8.40, window=0, period=0, false, USER_REQUEST]\n EventLogger: isPlaying [eventTime=9.40, mediaPos=8.40, window=0, period=0, false]\n EventLogger: playWhenReady [eventTime=10.40, mediaPos=8.40, window=0, period=0, true, USER_REQUEST]\n EventLogger: isPlaying [eventTime=10.40, mediaPos=8.40, window=0, period=0, true]\n EventLogger: state [eventTime=20.40, mediaPos=18.40, window=0, period=0, ENDED]\n EventLogger: isPlaying [eventTime=20.40, mediaPos=18.40, window=0, period=0, false]\n\nIn this example playback starts 0.93 seconds after the player is prepared. The\nuser pauses playback after 9.4 seconds, and resumes playback one second later at\n10.4 seconds. Playback ends ten seconds later at 20.4 seconds. The common\nelements within the square brackets are:\n\n- `[eventTime=float]`: The wall clock time since player creation.\n- `[mediaPos=float]`: The current playback position.\n- `[window=int]`: The current window index.\n- `[period=int]`: The current period in that window.\n\nThe final elements in each line indicate the value of the state being reported.\n\n### Media tracks\n\nTrack information is logged when the available or selected tracks change. This\nhappens at least once at the start of playback. The example below shows track\nlogging for an adaptive stream: \n\n EventLogger: tracks [eventTime=0.30, mediaPos=0.00, window=0, period=0,\n EventLogger: group [\n EventLogger: [X] Track:0, id=133, mimeType=video/avc, bitrate=261112, codecs=avc1.4d4015, res=426x240, fps=30.0, supported=YES\n EventLogger: [X] Track:1, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0, supported=YES\n EventLogger: [X] Track:2, id=135, mimeType=video/avc, bitrate=1204535, codecs=avc1.4d401f, res=854x480, fps=30.0, supported=YES\n EventLogger: [X] Track:3, id=160, mimeType=video/avc, bitrate=112329, codecs=avc1.4d400c, res=256x144, fps=30.0, supported=YES\n EventLogger: [ ] Track:4, id=136, mimeType=video/avc, bitrate=2400538, codecs=avc1.4d401f, res=1280x720, fps=30.0, supported=NO_EXCEEDS_CAPABILITIES\n EventLogger: ]\n EventLogger: group [\n EventLogger: [ ] Track:0, id=139, mimeType=audio/mp4a-latm, bitrate=48582, codecs=mp4a.40.5, channels=2, sample_rate=22050, supported=YES\n EventLogger: [X] Track:1, id=140, mimeType=audio/mp4a-latm, bitrate=127868, codecs=mp4a.40.2, channels=2, sample_rate=44100, supported=YES\n EventLogger: ]\n EventLogger: ]\n\nIn this example, the player has selected four of the five available video\ntracks. The fifth video track is not selected because it exceeds the\ncapabilities of the device, as indicated by `supported=NO_EXCEEDS_CAPABILITIES`.\nThe player will adapt between the selected video tracks during playback. When\nthe player adapts from one track to another, it's logged in a line like the one\nbelow: \n\n EventLogger: downstreamFormat [eventTime=3.64, mediaPos=3.00, window=0, period=0, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0]\n\nThis log line indicates that the player switched to the 640x360 resolution video\ntrack three seconds into the media.\n\n### Decoder selection\n\nIn most cases, ExoPlayer renders media using a `MediaCodec` acquired from the\nunderlying platform. When a decoder is initialized, this is logged in lines like\nthese: \n\n EventLogger: videoDecoderInitialized [0.77, 0.00, window=0, period=0, video, OMX.qcom.video.decoder.avc]\n EventLogger: audioDecoderInitialized [0.79, 0.00, window=0, period=0, audio, OMX.google.aac.decoder]"]]