I am using following test stream to render mpd in android exoplayer
https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/mpds/11331.mpd
following is my exoplayer code:
val adaptiveTrackSelection = AdaptiveTrackSelection.Factory()
val trackSelector: TrackSelector = DefaultTrackSelector(mContext!!, adaptiveTrackSelection)
mConcatenatingMediaSource = ConcatenatingMediaSource()
val mediaItem = MediaItem.Builder().setUri(url).setMimeType(MimeTypes.APPLICATION_MPD)
.build()
val dashMediaSource = DashMediaSource.Factory(DefaultDataSourceFactory(mContext!!, mContext!!.packageName))
.createMediaSource(mediaItem)
mConcatenatingMediaSource.addMediaSource(dashMediaSource)
exoPlayer = SimpleExoPlayer.Builder(this).setTrackSelector(trackSelector).build()
.also { exoPlayer ->
exoPlayer.playWhenReady = true
exoPlayer.addMediaSource(mConcatenatingMediaSource as MediaSource)
playerView!!.player = exoPlayer
exoPlayer.prepare()
attachEventListener(exoPlayer)
}
I am getting player state STATE_READY, I am getting position update for each second and finally player state STATE_ENDED as well, but on screen it is always a blank screen. I am testing on samsung device with os android 12.
Can anyone please help me solve this issue.
The link you have shared is to a DRM protected video stream and the behaviour you are seeing is consistent with the player not displaying encrypted content.
If you just want to test ExoPlayer in general then you can simple choose a different stream which is not DRM protected.
If you do want to test this particular stream then you will need to set up the DRM information in ExoPLayer.
The ExoPlayer documentation provides guidance on this including the example below (https://exoplayer.dev/drm.html):
MediaItem mediaItem = new MediaItem.Builder()
.setUri(videoUri)
.setDrmConfiguration(
new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
.setLicenseUri(licenseUri)
.setMultiSession(true)
.setLicenseRequestHeaders(httpRequestHeaders)
.build())
.build();
This is for Widevine which is the default DRM on Android and which your stream supports. You can see this by looking in the manifest you linked to and you will see the Widevine UUID listed in a Content protection element.
ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
As an FYI, the full list of DRM UUID's is here: https://dashif.org/identifiers/content_protection/
Related
I am trying to integrate subtitles into videos using Exoplayer. Currently only .srt subtitle files are working with MIMETypes.APPLICATION_SUBRIP. How do I make it work for .smi subtitle files.
MediaItem.SubtitleConfiguration subtitleConfiguration = new MediaItem.SubtitleConfiguration.Builder(Uri.parse(subTitlePath))
.setMimeType(MimeTypes.APPLICATION_SUBRIP)//mime type
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
.build();
MediaItem mediaItem=new MediaItem.Builder()
.setUri(Uri.parse(videoUri))
.setSubtitleConfigurations(ImmutableList.of(subtitleConfiguration))
.build();
According to below thread (issue in github),
Ref : https://github.com/google/ExoPlayer/issues/5869
The answer is that it is not possible to play that with the ExoPlayer at the moment, because we don't have a decoder for SAMI subtitles.
But in the future may we have the decoder and more support from ExoPlayer.
I'm working with the Pac-12 API (college sports data) and trying to make a streaming video player.
The Pac-12 API (http://api.pac-12.com/v3/vod?page=0") gives back a list of video objects with urls for their Video's on Demand (VODs).
I have exo player set up in Android and it's working for videos with urls that end in .mp4.
But when I try to plug in the VOD urls it's giving an error that it cannot extract the file type.
I'm using exo player 2.8.4 which may or may not be the problem. But the newer version of exo player ( 2.9.0 and above ) has min sdk 26 (which my testing phone doesn't run).
I'm working on checking if that's the problem, but in the mean time I wanted to post this question in case anyone can help.
Here is my exo player set up. mediaUrl is the varaible that works with .mp4 but not the VOD url.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
context, Util.getUserAgent(context, "RecyclerView VideoPlayer"));
String mediaUrl = mediaObjects.get(targetPosition).getMedia_url();
if (mediaUrl != null) {
MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(mediaUrl));
videoPlayer.prepare(videoSource);
videoPlayer.setPlayWhenReady(true);
}
The VOD urls give no file type extension at the end, so I tried concatenating '.vod' onto the mediaUrl varaible, but no luck with that.
From reading around online it seems like VODs are supported by exo player, but I can't find much about how the setup might be different.
Heres a direct link to one of the Pac-12 VODs. This is the same url as what the API returns.
https://pac-12.com/videos/oregons-dana-altman-talks-andy-katz-about-recruitment-getting-fans-back-and-more
I'm attempting to use the MediaItem class to load videos and show subtitles on the exoplayer2 CastPlayer. I'm able to see subtitles on the phone before casting and the video plays fine when cast to a TV using application/dash+xml format. However, I'm not able to figure out how to get subtitles to appear on the TV. I have added the MediaItem.Subtitle using MediaItem.Builder().setSubtitles(subtitleList). Previously I was able to do so with the deprecated MediaInfo class. I can't see any methods in the CastPlayer class to turn them on or how to customize the PlayerControlView to add a subtitle/caption button. Any ideas are greatly appreciated.
List<MediaItem.Subtitle> subtitleList = new ArrayList<>();
MediaItem.Subtitle externalSubtitle = new MediaItem.Subtitle(Uri.parse(url), MimeTypes.TEXT_VTT,"en", C.SELECTION_FLAG_DEFAULT, C.ROLE_FLAG_SUBTITLE, "ENGLISH-EXTERNAL");
subtitleList.add(externalSubtitle);
MediaItem mediaItem = new MediaItem.Builder()
.setUri(url)
.setMediaMetadata(mediaMetadata)
.setMimeType(mimeType)
.setSubtitles(subtitleList)
.build();
castPlayer.setMediaItem(mMediaItem);
i am newbie here. i am developing a android app to listen to online radio stations.
problem i am getting here is ExoPlayer(2.9.2) can or cant play some streams of same type of different bitrates.
For Example
These mpga streams
http://108.61.34.50:7130/ ---> 96kbs ===> Playable
http://s3.voscast.com:8408 ---> 64kbs ===> Not Playable
http://220.247.227.20:8000/citystream ---> 128kbs ===> Not Playable
i used vlc codec window to get this information, and those 3 streams share same values other than bitrate.
i am using ExtractorMediaSource
songs.add(Uri.parse("http://220.247.227.20:8000/citystream"));//City
player= ExoPlayerFactory.newSimpleInstance(this,
new DefaultTrackSelector());
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "AudioApp"));
ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource();
for (Uri temp : songs)
{
BaseMediaSource mediaSourse=
new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(temp);
concatenatingMediaSource.addMediaSource(mediaSourse);
}
player.prepare(concatenatingMediaSource);
player.setPlayWhenReady(true);
Hope anyone can help me out..
After testing various different streams, i realized that this is a device specific error.
Huawei Y5 2017
the other phone's that i tested work pretty well and i ended up submiting issue to ExpoPlayer team on github without knowing this is device specific issue.
Here it is
Why does ExoPlayer cant play some of the streams of same type with different bitrates ?
I have a list of HLS urls that I need to play consecutively with exoplayer 2. This is not a problem:
val mediaSources = arrayOfNulls<MediaSource>(videoModel.Clips.size)
for (i in videoModel.Clips.indices) {
mediaSources[i] = buildVideoSource(videoModel.Clips.get(i).StreamUrl)
}
val videoSource = if (mediaSources.size == 1) mediaSources[0] else ConcatenatingMediaSource(*mediaSources)
The problem here is that I need to mute these videos, and play a mp3 audio track instead as background tune. How should I go about this? I thought I could just use a MergingMediaSource like this:
val audioSource = buildAudioSource()
val mergedSource = MergingMediaSource(videoSource, audioSource)
player!!.prepare(videoSource)
But that throws the following error: The merge failed because the sources have different period counts.
Source error:
com.google.android.exoplayer2.source.MergingMediaSource$IllegalMergeException
at com.google.android.exoplayer2.source.MergingMediaSource.checkTimelineMerges(MergingMediaSource.java:169)
at com.google.android.exoplayer2.source.MergingMediaSource.handleSourceInfoRefreshed(MergingMediaSource.java:144)
at com.google.android.exoplayer2.source.MergingMediaSource.access$000(MergingMediaSource.java:34)
at com.google.android.exoplayer2.source.MergingMediaSource$1.onSourceInfoRefreshed(MergingMediaSource.java:102)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.handleSourceInfoRefreshed(ConcatenatingMediaSource.java:142)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.access$000(ConcatenatingMediaSource.java:34)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource$1.onSourceInfoRefreshed(ConcatenatingMediaSource.java:81)
at com.google.android.exoplayer2.source.hls.HlsMediaSource.onPrimaryPlaylistRefreshed(HlsMediaSource.java:142)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker.onPlaylistUpdated(HlsPlaylistTracker.java:385)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker.access$1200(HlsPlaylistTracker.java:41)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.processLoadedPlaylist(HlsPlaylistTracker.java:590)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.onLoadCompleted(HlsPlaylistTracker.java:539)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.onLoadCompleted(HlsPlaylistTracker.java:472)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.handleMessage(Loader.java:383)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
I have 2 questions:
How can I mute incoming HLS stream? I'd preferably not load the audio at all to save data usage.
How can I play a seperate audiotrack under a ConcatenatingMediaSource?
u can disable audio , in exo player Demo application, you can select audio button and choose disable.
you can see the demo code to see how disable the audio