-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
Armadillo/src/main/java/com/scribd/armadillo/playback/ArmadilloAnalyticsListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.scribd.armadillo.playback | ||
|
||
import com.google.android.exoplayer2.analytics.AnalyticsListener | ||
import com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime | ||
import com.google.android.exoplayer2.source.LoadEventInfo | ||
import com.google.android.exoplayer2.source.MediaLoadData | ||
import com.google.android.exoplayer2.util.Log | ||
import java.io.IOException | ||
import java.lang.Exception | ||
|
||
class ArmadilloAnalyticsListener : AnalyticsListener { | ||
override fun onLoadStarted( | ||
eventTime: EventTime, | ||
loadEventInfo: LoadEventInfo, | ||
mediaLoadData: MediaLoadData | ||
) { | ||
// Called when a media load starts | ||
Log.e(TAG, "Load started: ${loadEventInfo.describe()}") | ||
} | ||
|
||
override fun onLoadCompleted( | ||
eventTime: EventTime, | ||
loadEventInfo: LoadEventInfo, | ||
mediaLoadData: MediaLoadData | ||
) { | ||
// Called when a media load completes | ||
Log.e(TAG, "Load completed: ${loadEventInfo.describe()}") | ||
} | ||
|
||
override fun onLoadCanceled( | ||
eventTime: EventTime, | ||
loadEventInfo: LoadEventInfo, | ||
mediaLoadData: MediaLoadData | ||
) { | ||
// Called when a media load is canceled | ||
Log.e(TAG, "Load canceled: ${loadEventInfo.describe()}") | ||
} | ||
|
||
override fun onLoadError( | ||
eventTime: EventTime, | ||
loadEventInfo: LoadEventInfo, | ||
mediaLoadData: MediaLoadData, | ||
error: IOException, | ||
wasCanceled: Boolean | ||
) { | ||
// Called when a media load encounters an error | ||
Log.e(TAG, "Load error: ${loadEventInfo.describeWithError(error, wasCanceled)}") | ||
} | ||
|
||
companion object { | ||
private const val TAG = "ArmListener" | ||
} | ||
} | ||
|
||
fun LoadEventInfo.describe(): String { | ||
return "${dataSpec.uri} pos: ${dataSpec.position}, len: ${dataSpec.length}" | ||
} | ||
|
||
fun LoadEventInfo.describeWithError(exception: Exception, wasCanceled: Boolean): String { | ||
return "ERR: ${exception.message}: wasCanceled: $wasCanceled, ${dataSpec.uri} pos: ${dataSpec.position}, len: ${dataSpec.length}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters