первое следующее:
Ошибка сеанса DRM
androidx.media3.exoplayer.drm.MediaDrmCallbackException: androidx.media3.datasource.HttpDataSource$HttpDataSourceException: java.net.MalformedURLException: неизвестный протокол: данные
секунда:
Ошибка воспроизведения
androidx.media3.exoplayer.ExoPlaybackException: ошибка источникаat androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:736)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:690)
at android.os. Handler.dispatchMessage(Handler.java:102)
в android.os.Looper.loopOnce(Looper.java:201)
в android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Вызвано: androidx.media3.exoplayer.drm.DrmSession$DrmSessionException: androidx.media3.exoplayer.drm.MediaDrmCallbackException: androidx.media3. datasource.HttpDataSource$HttpDataSourceException: java.net.MalformedURLException: неизвестный протокол: данные
это весь мой код:
Код: Выделить всё
public class MainActivity extends AppCompatActivity {
private PlayerView playerView;
private ExoPlayer player;
// ClearKey DRM Information
private static final String STREAM_URL = "https://live4.shoq.com.pk/live/eds/PTV_Sports/DASH/PTV_Sports.mpd?|drmScheme=clearkey&drmLicense=9ecad6c4413f8bdc54712ce6c072a2cf:442df559c369bdada8ba3abe97811575";
private static final String DRM_KEY_ID = "9ecad6c4413f8bdc54712ce6c072a2cf";
private static final String DRM_KEY = "442df559c369bdada8ba3abe97811575";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the content view to your layout
setContentView(R.layout.activity_main);
// Initialize the PlayerView
playerView = findViewById(R.id.player_view);
// Initialize the ExoPlayer
initializePlayer();
}
private void initializePlayer() {
// Create a new ExoPlayer instance
player = new ExoPlayer.Builder(this).build();
// Bind the player to the view
playerView.setPlayer(player);
// Build the MediaItem with DRM configuration for ClearKey
MediaItem mediaItem = new MediaItem.Builder()
.setUri(Uri.parse(STREAM_URL)) // Stream URL
.setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.CLEARKEY_UUID) // ClearKey UUID
.setLicenseUri("data:application/json;base64," + getClearKeyLicense()) // License in base64
.build())
.build();
// Set the MediaItem to the player
player.setMediaItem(mediaItem);
// Prepare the player
player.prepare();
// Start playback automatically
player.play();
}
/**
* Generates the ClearKey license in base64-encoded JSON format.
*
* @return Base64-encoded license string.
*/
private String getClearKeyLicense() {
// ClearKey requires the license to be in JSON format with keys array
String jsonLicense = "{"
+ "\"keys\": [{"
+ "\"kty\": \"oct\","
+ "\"kid\": \"" + DRM_KEY_ID + "\","
+ "\"k\": \"" + DRM_KEY + "\""
+ "}],"
+ "\"type\": \"temporary\""
+ "}";
// Encode the JSON license to base64
return android.util.Base64.encodeToString(jsonLicense.getBytes(), android.util.Base64.NO_WRAP);
}
@Override
protected void onStart() {
super.onStart();
if (player == null) {
initializePlayer();
}
}
@Override
protected void onResume() {
super.onResume();
if (player != null) {
player.play();
}
}
@Override
protected void onPause() {
super.onPause();
if (player != null) {
player.pause();
}
}
@Override
protected void onStop() {
super.onStop();
releasePlayer();
}
/**
* Releases the ExoPlayer instance.
*/
private void releasePlayer() {
if (player != null) {
player.release();
player = null;
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... back-error