yuliskov/SmartTube · error · IllegalStateException
Unsupported type: ${type}
Error message
Unsupported type: ${type} What it means
buildMediaSource switches on Util.inferContentType(uri) and handles only C.TYPE_SS, C.TYPE_DASH, C.TYPE_HLS and C.TYPE_OTHER; every other value lands in the default branch and throws IllegalStateException with the numeric type. Older stock ExoPlayer inference falls back to TYPE_OTHER, so in practice this throw means the running ExoPlayer build can infer a type this factory was never written to handle (e.g. C.TYPE_RTSP) or a patched Util returns something unexpected.
Source
Thrown at common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/ExoMediaSourceFactory.java:179
dashSource.addEventListener(Utils.sHandler, mTrackErrorFixer);
}
return dashSource;
case C.TYPE_HLS:
HlsMediaSource hlsSource = new HlsMediaSource.Factory(getMediaDataSourceFactory()).createMediaSource(uri);
if (mTrackErrorFixer != null) {
hlsSource.addEventListener(Utils.sHandler, mTrackErrorFixer);
}
return hlsSource;
case C.TYPE_OTHER:
ExtractorMediaSource extractorSource = new ExtractorMediaSource.Factory(getMediaDataSourceFactory())
.setExtractorsFactory(new DefaultExtractorsFactory())
.createMediaSource(uri);
if (mTrackErrorFixer != null) {
extractorSource.addEventListener(Utils.sHandler, mTrackErrorFixer);
}
return extractorSource;
default: {
throw new IllegalStateException("Unsupported type: " + type);
}
}
}
private MediaSource buildSabrMediaSource(MediaItemFormatInfo formatInfo) {
// Are you using FrameworkSampleSource or ExtractorSampleSource when you build your player?
SabrMediaSource sabrSource = new SabrMediaSource.Factory(
getSabrChunkSourceFactory(),
null
)
.setLoadErrorHandlingPolicy(new SabrDefaultLoadErrorHandlingPolicy())
.createMediaSource(getSabrManifest(formatInfo));
if (mTrackErrorFixer != null) {
sabrSource.addEventListener(Utils.sHandler, mTrackErrorFixer);
}
return sabrSource;
}
View on GitHub (pinned to 3de8d90593)
Solutions
- Inspect the numeric type in the exception message — it identifies exactly which constant escaped the switch
- Restrict playable URLs to schemes this factory maps: http/https progressive, .mpd, .m3u8, smooth streaming
- If you maintain this fork, add the missing case (e.g. map C.TYPE_RTSP to an RtspMediaSource) or deliberately coerce it to TYPE_OTHER
- Keep the ExoPlayer dependency and this factory in lockstep when upgrading
Example fix
// before
default:
throw new IllegalStateException("Unsupported type: " + type);
// after
case C.TYPE_RTSP:
return new RtspMediaSource.Factory().createMediaSource(uri);
default:
throw new IllegalStateException("Unsupported type: " + type); Defensive patterns
Strategy: try-catch
Validate before calling
int inferred = Util.inferContentType(uri);
boolean supported = inferred == C.TYPE_SS || inferred == C.TYPE_DASH
|| inferred == C.TYPE_HLS || inferred == C.TYPE_OTHER;
if (!supported) {
// reject or substitute a safe url before invoking the player
} Try / catch
try {
MediaSource source = mediaSourceFactory.getMediaSource(formatInfo);
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unsupported type")) {
// log the uri and the numeric type, skip this source / fall back to another format
} else {
throw e;
}
} Prevention
- Whitelist url schemes/extensions (http/https, .mpd, .m3u8, .ism) before playback
- When upgrading ExoPlayer, diff the C.TYPE_* constants against this factory's switch
- Map any newly supported type in the switch instead of relying on the default branch
When it happens
Trigger: A URI whose inferred content type is outside {TYPE_SS, TYPE_DASH, TYPE_HLS, TYPE_OTHER}, e.g. an rtsp:// URL under an ExoPlayer where Util.inferContentType returns C.TYPE_RTSP; overriding the extension with a value that infers to an unhandled constant.
Common situations: Upgrading or repackaging ExoPlayer adds new C.TYPE_* values while ExoMediaSourceFactory keeps the old switch; attempting rtsp/udp or other exotic schemes in a player tuned for YouTube http/hls/dash; modified Util.inferContentType in a forked ExoPlayer.
Related errors
AI-assisted analysis of yuliskov/SmartTube@3de8d90593 (2026-08-22).
Data as JSON: /api/errors/3a97020c4d4fc172.
Report an issue: GitHub.