From fdfc8d66792e87fa121f1db2ed367b313b671c46 Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 23 Dec 2024 11:39:31 +0530 Subject: [PATCH 1/7] fix --- .../main/java/com/tpstream/player/constants/PlaybackError.kt | 1 + .../java/com/tpstream/player/ui/TpStreamPlayerFragment.kt | 4 +++- player/src/main/res/layout/fragment_tp_stream_player.xml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt index 4d4b1544..f6049f93 100644 --- a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt +++ b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt @@ -49,6 +49,7 @@ internal fun PlaybackException.getErrorMessage(playerId: String): String { PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "The request took too long to process due to a slow or unstable network connection. Please try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "There was an issue fetching the license key for this video. Please try again later.\n Player code: ${this.errorCode}. Player Id: $playerId" + PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, see HELP.\n Player code: ${this.errorCode}. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Player code: ${this.errorCode}. Player Id: $playerId" } } diff --git a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt index 1e9320dd..982b6816 100644 --- a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt +++ b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt @@ -3,7 +3,9 @@ package com.tpstream.player.ui import android.app.Dialog import android.content.pm.ActivityInfo import android.media.MediaCodec +import android.net.ConnectivityManager import android.os.Bundle +import android.text.Html import android.util.Log import android.view.LayoutInflater import android.view.View @@ -395,7 +397,7 @@ class TpStreamPlayerFragment : Fragment(), DownloadCallback.Listener { private fun showErrorMessage(message: String) { if (!this@TpStreamPlayerFragment.isAdded) return viewBinding.errorMessage.visibility = View.VISIBLE - viewBinding.errorMessage.text = message + viewBinding.errorMessage.text = Html.fromHtml(message) } private val tpStreamPlayerImplCallBack = object :TpStreamPlayerImplCallBack{ diff --git a/player/src/main/res/layout/fragment_tp_stream_player.xml b/player/src/main/res/layout/fragment_tp_stream_player.xml index 5a66042c..189506dd 100644 --- a/player/src/main/res/layout/fragment_tp_stream_player.xml +++ b/player/src/main/res/layout/fragment_tp_stream_player.xml @@ -20,6 +20,8 @@ android:textStyle="bold" android:visibility="gone" android:textAlignment="center" + android:linksClickable="true" + android:autoLink="web" android:textSize="14dp" android:text=""/> From 88db85a86176db0456f42792756994523d8ac224 Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 23 Dec 2024 14:37:40 +0530 Subject: [PATCH 2/7] fix --- .../main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt index 982b6816..00f52670 100644 --- a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt +++ b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt @@ -3,7 +3,6 @@ package com.tpstream.player.ui import android.app.Dialog import android.content.pm.ActivityInfo import android.media.MediaCodec -import android.net.ConnectivityManager import android.os.Bundle import android.text.Html import android.util.Log From d8d59c578175229974196fddaf810ee59aae922f Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 23 Dec 2024 19:04:48 +0530 Subject: [PATCH 3/7] fix --- .../java/com/tpstream/player/constants/PlaybackError.kt | 6 +++--- .../java/com/tpstream/player/ui/TpStreamPlayerFragment.kt | 2 +- player/src/main/res/layout/fragment_tp_stream_player.xml | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt index f6049f93..a83fce3a 100644 --- a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt +++ b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt @@ -35,8 +35,8 @@ internal fun PlaybackException.toError(): PlaybackError { internal fun TPException.getErrorMessage(playerId: String): String { return when { - this.isNetworkError() -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Error code: 5004. Player Id: $playerId" - this.response?.code == 404 -> "The video is not available. Please try another one.\n Error code: 5001. Player Id: $playerId" + this.isNetworkError() -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${4001}. Player Id: $playerId" + this.response?.code == 404 -> "The video is not available. Please try another one.\n Error code: 5001. Player Id: $playerId" this.isUnauthenticated() -> "Sorry, you don't have permission to access this video. Please check your credentials and try again.\n Error code: 5002. Player Id: $playerId" this.isServerError() -> "We're sorry, but there's an issue on our server. Please try again later.\n Error code: 5005. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Error code: 5100. Player Id: $playerId" @@ -49,7 +49,7 @@ internal fun PlaybackException.getErrorMessage(playerId: String): String { PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "The request took too long to process due to a slow or unstable network connection. Please try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "There was an issue fetching the license key for this video. Please try again later.\n Player code: ${this.errorCode}. Player Id: $playerId" - PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, see HELP.\n Player code: ${this.errorCode}. Player Id: $playerId" + PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${this.errorCode}. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Player code: ${this.errorCode}. Player Id: $playerId" } } diff --git a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt index 00f52670..16db09dc 100644 --- a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt +++ b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt @@ -396,7 +396,7 @@ class TpStreamPlayerFragment : Fragment(), DownloadCallback.Listener { private fun showErrorMessage(message: String) { if (!this@TpStreamPlayerFragment.isAdded) return viewBinding.errorMessage.visibility = View.VISIBLE - viewBinding.errorMessage.text = Html.fromHtml(message) + viewBinding.errorMessage.text = message } private val tpStreamPlayerImplCallBack = object :TpStreamPlayerImplCallBack{ diff --git a/player/src/main/res/layout/fragment_tp_stream_player.xml b/player/src/main/res/layout/fragment_tp_stream_player.xml index 189506dd..8d3c3504 100644 --- a/player/src/main/res/layout/fragment_tp_stream_player.xml +++ b/player/src/main/res/layout/fragment_tp_stream_player.xml @@ -19,6 +19,7 @@ android:layout_gravity="center" android:textStyle="bold" android:visibility="gone" + android:padding="32dp" android:textAlignment="center" android:linksClickable="true" android:autoLink="web" From 703c51661e3736eed151d37f6922989850c399f7 Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 23 Dec 2024 19:07:43 +0530 Subject: [PATCH 4/7] fix --- .../java/com/tpstream/player/constants/PlaybackError.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt index a83fce3a..45bdf734 100644 --- a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt +++ b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt @@ -35,8 +35,8 @@ internal fun PlaybackException.toError(): PlaybackError { internal fun TPException.getErrorMessage(playerId: String): String { return when { - this.isNetworkError() -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${4001}. Player Id: $playerId" - this.response?.code == 404 -> "The video is not available. Please try another one.\n Error code: 5001. Player Id: $playerId" + this.isNetworkError() -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Error code: 5004. Player Id: $playerId" + this.response?.code == 404 -> "The video is not available. Please try another one.\n Error code: 5001. Player Id: $playerId" this.isUnauthenticated() -> "Sorry, you don't have permission to access this video. Please check your credentials and try again.\n Error code: 5002. Player Id: $playerId" this.isServerError() -> "We're sorry, but there's an issue on our server. Please try again later.\n Error code: 5005. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Error code: 5100. Player Id: $playerId" @@ -49,7 +49,7 @@ internal fun PlaybackException.getErrorMessage(playerId: String): String { PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "The request took too long to process due to a slow or unstable network connection. Please try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "There was an issue fetching the license key for this video. Please try again later.\n Player code: ${this.errorCode}. Player Id: $playerId" - PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${this.errorCode}. Player Id: $playerId" + PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\\n Player code: ${this.errorCode}. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Player code: ${this.errorCode}. Player Id: $playerId" } } From 48ba6cb03b0ac1344479fbe2a5d3488c2a0f458a Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 23 Dec 2024 19:12:10 +0530 Subject: [PATCH 5/7] fix --- .../main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt index 16db09dc..1e9320dd 100644 --- a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt +++ b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt @@ -4,7 +4,6 @@ import android.app.Dialog import android.content.pm.ActivityInfo import android.media.MediaCodec import android.os.Bundle -import android.text.Html import android.util.Log import android.view.LayoutInflater import android.view.View From 81b96b1da00b5d705cebd1cdbc3fdc7232dbb1ea Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 13 Jan 2025 13:41:08 +0530 Subject: [PATCH 6/7] fix --- .../main/java/com/tpstream/player/constants/PlaybackError.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt index 45bdf734..1453e9de 100644 --- a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt +++ b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt @@ -49,7 +49,7 @@ internal fun PlaybackException.getErrorMessage(playerId: String): String { PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "The request took too long to process due to a slow or unstable network connection. Please try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "There was an issue fetching the license key for this video. Please try again later.\n Player code: ${this.errorCode}. Player Id: $playerId" - PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "There was an issue initializing the video decoder. Please try restarting your device or playing a different video. For more details, visit https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\\n Player code: ${this.errorCode}. Player Id: $playerId" + PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "An error occurred while playing the video. Try restarting your device or playing another video. More help: https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${this.errorCode}. Player Id: $playerId" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Player code: ${this.errorCode}. Player Id: $playerId" } } From c2054b8910c8cca54195d83570809a7c67f82654 Mon Sep 17 00:00:00 2001 From: PruthiviRaj27 Date: Mon, 13 Jan 2025 17:33:50 +0530 Subject: [PATCH 7/7] fix --- .../player/constants/PlaybackError.kt | 2 +- .../player/ui/TpStreamPlayerFragment.kt | 23 ++++++++++++++++++- .../res/layout/fragment_tp_stream_player.xml | 2 -- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt index 1453e9de..b93d4d67 100644 --- a/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt +++ b/player/src/main/java/com/tpstream/player/constants/PlaybackError.kt @@ -49,7 +49,7 @@ internal fun PlaybackException.getErrorMessage(playerId: String): String { PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Oops! It seems like you're not connected to the internet. Please check your connection and try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "The request took too long to process due to a slow or unstable network connection. Please try again.\n Player code: ${this.errorCode}. Player Id: $playerId" PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "There was an issue fetching the license key for this video. Please try again later.\n Player code: ${this.errorCode}. Player Id: $playerId" - PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "An error occurred while playing the video. Try restarting your device or playing another video. More help: https://tpstreams.com/help/troubleshooting-steps-for-error-code-4001.\n Player code: ${this.errorCode}. Player Id: $playerId" + PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "

An error occurred while playing the video. Try restarting your device or playing another video. More help click here.
Player code: ${this.errorCode}. Player Id: $playerId

" else -> "Oops! Something went wrong. Please contact support for assistance and provide details about the issue.\n Player code: ${this.errorCode}. Player Id: $playerId" } } diff --git a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt index 1e9320dd..a4295c09 100644 --- a/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt +++ b/player/src/main/java/com/tpstream/player/ui/TpStreamPlayerFragment.kt @@ -3,12 +3,16 @@ package com.tpstream.player.ui import android.app.Dialog import android.content.pm.ActivityInfo import android.media.MediaCodec +import android.os.Build import android.os.Bundle +import android.text.Html +import android.text.method.LinkMovementMethod import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageButton +import android.widget.TextView import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import com.tpstream.player.* @@ -395,7 +399,24 @@ class TpStreamPlayerFragment : Fragment(), DownloadCallback.Listener { private fun showErrorMessage(message: String) { if (!this@TpStreamPlayerFragment.isAdded) return viewBinding.errorMessage.visibility = View.VISIBLE - viewBinding.errorMessage.text = message + if (isDecoderError(message)) { + viewBinding.errorMessage.setHtmlText(message) + } else { + viewBinding.errorMessage.text = message + } + } + + private fun isDecoderError(message: String): Boolean { + return listOf("4001", "4003").any { message.contains(it) } + } + + private fun TextView.setHtmlText(message: String) { + movementMethod = LinkMovementMethod.getInstance() + text = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY) + } else { + Html.fromHtml(message) + } } private val tpStreamPlayerImplCallBack = object :TpStreamPlayerImplCallBack{ diff --git a/player/src/main/res/layout/fragment_tp_stream_player.xml b/player/src/main/res/layout/fragment_tp_stream_player.xml index 8d3c3504..51d0623f 100644 --- a/player/src/main/res/layout/fragment_tp_stream_player.xml +++ b/player/src/main/res/layout/fragment_tp_stream_player.xml @@ -21,8 +21,6 @@ android:visibility="gone" android:padding="32dp" android:textAlignment="center" - android:linksClickable="true" - android:autoLink="web" android:textSize="14dp" android:text=""/>