From bd56a2bd1638b4ed2fc4c36fd6c91589dfb32194 Mon Sep 17 00:00:00 2001 From: Reza Amuzadeh Date: Mon, 19 Aug 2019 10:48:45 +0330 Subject: [PATCH] Added Error CallBack --- .../java/com/potyvideo/andexoplayer/MainActivity.java | 1 + app/src/main/res/layout/activity_main.xml | 6 ------ library/build.gradle | 4 ++-- .../java/com/potyvideo/library/AndExoPlayerView.java | 10 ++++++++++ .../library/globalInterfaces/ExoPlayerCallBack.java | 6 ++++++ 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 library/src/main/java/com/potyvideo/library/globalInterfaces/ExoPlayerCallBack.java diff --git a/app/src/main/java/com/potyvideo/andexoplayer/MainActivity.java b/app/src/main/java/com/potyvideo/andexoplayer/MainActivity.java index 4e83a11..cc16d17 100644 --- a/app/src/main/java/com/potyvideo/andexoplayer/MainActivity.java +++ b/app/src/main/java/com/potyvideo/andexoplayer/MainActivity.java @@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity; import com.potyvideo.library.AndExoPlayerView; +import com.potyvideo.library.globalInterfaces.ExoPlayerCallBack; import com.potyvideo.library.utils.PathUtil; import com.potyvideo.library.utils.PublicFunctions; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5a6d9b0..04b7dd6 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -60,12 +60,6 @@ android:padding="@dimen/global_padding_extra" android:text="SOME OTHER VIEWS ;)" /> - - \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index 314122f..286e7c3 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 28 - versionCode 12 - versionName "1.0.12" + versionCode 13 + versionName "1.0.13" vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/library/src/main/java/com/potyvideo/library/AndExoPlayerView.java b/library/src/main/java/com/potyvideo/library/AndExoPlayerView.java index b4c53b7..c021f1b 100644 --- a/library/src/main/java/com/potyvideo/library/AndExoPlayerView.java +++ b/library/src/main/java/com/potyvideo/library/AndExoPlayerView.java @@ -48,6 +48,7 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.potyvideo.library.globalEnums.EnumAspectRatio; import com.potyvideo.library.globalEnums.EnumResizeMode; +import com.potyvideo.library.globalInterfaces.ExoPlayerCallBack; import com.potyvideo.library.utils.PublicFunctions; import com.potyvideo.library.utils.PublicValues; @@ -80,6 +81,8 @@ public class AndExoPlayerView extends LinearLayout implements View.OnClickListen private TrackSelection.Factory trackSelectionFactory; private TrackSelector trackSelector; + private ExoPlayerCallBack exoPlayerCallBack; + public class ComponentListener implements Player.EventListener { String TAG = AndExoPlayerView.ComponentListener.class.getSimpleName(); @@ -137,6 +140,9 @@ public void onLoadingChanged(boolean isLoading) { @Override public void onPlayerError(ExoPlaybackException error) { showRetry(); + + if (exoPlayerCallBack != null) + exoPlayerCallBack.onError(); } @Override @@ -505,6 +511,10 @@ public void onClick(View v) { } } + public void setExoPlayerCallBack(ExoPlayerCallBack exoPlayerCallBack) { + this.exoPlayerCallBack = exoPlayerCallBack; + } + private void enterFullScreen() { imageViewExitFullScreen.setVisibility(VISIBLE); imageViewEnterFullScreen.setVisibility(GONE); diff --git a/library/src/main/java/com/potyvideo/library/globalInterfaces/ExoPlayerCallBack.java b/library/src/main/java/com/potyvideo/library/globalInterfaces/ExoPlayerCallBack.java new file mode 100644 index 0000000..0de32c4 --- /dev/null +++ b/library/src/main/java/com/potyvideo/library/globalInterfaces/ExoPlayerCallBack.java @@ -0,0 +1,6 @@ +package com.potyvideo.library.globalInterfaces; + +public interface ExoPlayerCallBack { + + void onError(); +}