@@ -856,7 +856,7 @@ private AudioAsset loadAudioAsset(
856856 }
857857 }
858858
859- if (assetPath . endsWith ( ".m3u8" )) {
859+ if (isHlsUrl ( assetPath )) {
860860 // HLS Stream - check if HLS support is available
861861 if (!HlsAvailabilityChecker .isHlsAvailable ()) {
862862 throw new Exception (
@@ -1064,6 +1064,32 @@ private boolean isStringValid(String value) {
10641064 return (value != null && !value .isEmpty () && !value .equals ("null" ));
10651065 }
10661066
1067+ /**
1068+ * Check if the given URL is an HLS stream by examining the URL path.
1069+ * This handles URLs with query parameters correctly.
1070+ *
1071+ * @param assetPath The URL or path to check
1072+ * @return true if the URL path ends with .m3u8, false otherwise
1073+ */
1074+ private boolean isHlsUrl (String assetPath ) {
1075+ if (assetPath == null || assetPath .isEmpty ()) {
1076+ return false ;
1077+ }
1078+
1079+ try {
1080+ Uri uri = Uri .parse (assetPath );
1081+ String path = uri .getPath ();
1082+ if (path != null ) {
1083+ return path .toLowerCase ().endsWith (".m3u8" );
1084+ }
1085+ } catch (Exception e ) {
1086+ Log .w (TAG , "Failed to parse URL for HLS detection: " + assetPath , e );
1087+ }
1088+
1089+ // Fallback: check if the URL contains .m3u8 followed by nothing or query params
1090+ return assetPath .toLowerCase ().contains (".m3u8" );
1091+ }
1092+
10671093 /**
10681094 * Creates a StreamAudioAsset via reflection.
10691095 * This allows the StreamAudioAsset class to be excluded at compile time when HLS is disabled,
0 commit comments