Exoplayer2 not playing MPD video - android

I am building a video player which streams online videos with track selector. If I parse mp4 video, Exoplayer plays the video well but when the video has mpd format, it plays but with black screen.
My code:
val trackSelector = DefaultTrackSelector(context)
val url = "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd"
val simpleExoPlayer = SimpleExoPlayer.Builder(context).setTrackSelector(trackSelector).build()
simpleExoPlayer.setMediaItem(MediaItem.fromUri(url))
simpleExoPlayer.seekTo(0)
simpleExoPlayer.prepare()
I have tried the code above and it works with all formats excepts mdp format.

Related

Timebar/Seek Buttons are disabled in Exoplayer for some .mkv files and hevc files

It works for some mkv files perfectly but for some mkv files it does not show scrubber on time bar and when i try to seek video programmatically it starts from beginning
simplexo = ExoPlayer.Builder(this,DefaultRenderersFactory(this)).build()
val datasource = DefaultDataSourceFactory(this,Util.getUserAgent(this,"app"))
concatenate = ConcatenatingMediaSource()
val mediasource = ProgressiveMediaSource.Factory(datasource).createMediaSource(Uri.parse(ok.get(position.toInt()).path))
concatenate.addMediaSource(mediasource)
playerview.setPlayer(simplexo)
simplexo.prepare(concatenate)
simplexo.seekTo(position.toInt(),C.TIME_UNSET)
simplexo.setPlayWhenReady(true)

Android Exo Player - Trouble playing Video on Demand from API

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

Enable lazy buffering in ExoPlayer

I want to show video by http data source. but when I set data source, exoplayer immediately start to buffer video, How can start buffering on user play click.
val dataSourceFactory = DefaultDataSourceFactory(context,Util.getUserAgent(context!!,"user_agent"))
player = SimpleExoPlayer.Builder(context!!).build()
playerView!!.player = player
val contentUrl = "my video url.mp4"
videoSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(contentUrl))
player.prepare(videoSource)
P.S:
I try to change DefaultLoadControl to change buffering behavior but I cant find a workaround.
Thanks.

Exoplayer, play an audio stream and a video stream synchronously?

I am using the following code to play a stream (which has both a video and an audio). But what if I want a video stream and a separate audio stream for the video stream at the same time synchronously? For example, suppose there are
https://someserver.com/video1/video.mp4
https://someserver.com/video1/audio.mp3
Both video.mp4 and audio.mp3 belong to video1 and have the same length, 1:23:34. Can I play video.mp4 and audio.mp3 synchronously as if they were one stream, with one ExoPlayer? The user must be able to pause/play/seek, and the same action should be applied to both streams.
If not, and I have to use two ExoPlayers, one for video and one for audio, how can I synchronise the audio and the video?
var uri = Uri.parse(url);
var df = DefaultHttpDataSourceFactory(url);
var ms = ExtractorMediaSource(uri, df, DefaultExtractorsFactory(), null, null);
exoPlayer.playWhenReady=true;
exoPlayer.prepare(ms);
You can! This is done in ExoPlayer by creating a MergingMediaSource. The example in the link merges a video source with a subtitle source but it's even easier for audio and video:
MediaSource videoSource = new ProgressiveMediaSource.Factory(...)
.createMediaSource(videoUri);
MediaSource audioSource = new ProgressiveMediaSource.Factory(...)
.createMediaSource(audioUri);
MergingMediaSource mergedSource = new MergingMediaSource(videoSource, audioSource);

How to record video in iOS which will be played in android

I need to record video in iOS and want to play that video on android. I am using following code to record video in iOS via UIImagePickerController. The recorded video is played in iOS successfully but not in android. I am recording video in .mp4 format
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.showsCameraControls = false
self.imagePicker.mediaTypes = [kUTTypeMovie, kUTTypeImage]
self.imagePicker.videoMaximumDuration = 12
self.imagePicker.videoQuality = UIImagePickerControllerQualityType.TypeIFrame960x540
self.imagePicker.cameraFlashMode = .Off
self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Video

Categories

Resources