You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
//package com.xypower.mpremote;
|
|
|
|
|
//
|
|
|
|
|
//import androidx.media3.common.MediaItem;
|
|
|
|
|
//import androidx.media3.exoplayer.ExoPlayer;
|
|
|
|
|
//import androidx.media3.exoplayer.rtsp.RtspMediaSource;
|
|
|
|
|
//import androidx.media3.exoplayer.source.MediaSource;
|
|
|
|
|
//
|
|
|
|
|
//// 自定义 RtspMediaSource.Factory,移除 trackID 参数
|
|
|
|
|
//public class CustomRtspMediaSourceFactory extends RtspMediaSource.Factory {
|
|
|
|
|
// public CustomRtspMediaSourceFactory() {
|
|
|
|
|
// super();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public MediaSource createMediaSource(MediaItem mediaItem) {
|
|
|
|
|
// // 修改原始 URI,移除 trackID 参数
|
|
|
|
|
// String originalUri = mediaItem.getUri().toString();
|
|
|
|
|
// String modifiedUri = removeTrackIdParameter(originalUri);
|
|
|
|
|
//
|
|
|
|
|
// // 使用修改后的 URI 创建新的 MediaItem
|
|
|
|
|
// MediaItem modifiedMediaItem = mediaItem.buildUpon()
|
|
|
|
|
// .setUri(modifiedUri)
|
|
|
|
|
// .build();
|
|
|
|
|
//
|
|
|
|
|
// return super.createMediaSource(modifiedMediaItem);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 移除 URL 中的 trackID 参数
|
|
|
|
|
// private String removeTrackIdParameter(String url) {
|
|
|
|
|
// if (url.contains("trackID=")) {
|
|
|
|
|
// int index = url.indexOf("trackID=");
|
|
|
|
|
// int endIndex = url.indexOf("&", index);
|
|
|
|
|
// if (endIndex == -1) {
|
|
|
|
|
// // 如果 trackID 是最后一个参数,直接截断
|
|
|
|
|
// return url.substring(0, index - 1);
|
|
|
|
|
// } else {
|
|
|
|
|
// // 否则移除 trackID 参数段
|
|
|
|
|
// return url.substring(0, index) + url.substring(endIndex);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return url;
|
|
|
|
|
// }
|
|
|
|
|
//}
|