Exoplayer/Android Media Player Not Playing Video with AC3 Audio - android

I'm using Exoplayer version 2 for playing Video from Internal Storage and it works fine but whenever video contains ac3 type audio,exoplayer not plays audio,it only display video.
please help me
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayer2example"), bandwidthMeter);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory().setConstantBitrateSeekingEnabled(true);
videoSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
player.prepare(videoSource);
Same Problem also Occurring with Android Media player

Related

Exoplayer NO Sound while streaming m3u8

im currently doing a streaming app but i got an issue with exployer, some of my video link are playing fine with sound, but some is not, here is the sample streaming link i have
http://202.57.43.60:8443/live/5748aabe4c9d661afbd7f4068248f664/99.m3u8
and here is my code:
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
playerView = findViewById(R.id.movie_exo_player);
simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
simpleExoPlayer.setAudioAttributes(new AudioAttributes
.Builder().build());
playerView.setPlayer(simpleExoPlayer);
DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "Exo2"), defaultBandwidthMeter);
DefaultHlsExtractorFactory defaultHlsExtractorFactory = new DefaultHlsExtractorFactory(FLAG_ALLOW_NON_IDR_KEYFRAMES);
MediaSource mediaSource = new HlsMediaSource.Factory(dataSourceFactory)
.setExtractorFactory(defaultHlsExtractorFactory)
.createMediaSource(Uri.parse(VIDEO_TEST_URL));
LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);
simpleExoPlayer.prepare(loopingSource);
if(VIDEO_TEST_URL != null){
simpleExoPlayer.prepare(mediaSource);
simpleExoPlayer.setPlayWhenReady(true);
}
any form of help is much appreciated

My ExoPlayer is keeps on buffering even with good data connectivity

I am using ExoPlayer to play videos from URL. For some reason, my video keeps on buffering even it is low size video also. Please find the code snippet below which I have used to build ExoPlayer.
private MediaSource buildMediaStore(String mediaUrl) {
Uri videoUri = Uri.parse(mediaUrl);
DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(this, getApplicationInfo().packageName), defaultBandwidthMeter);
DefaultExtractorsFactory extractorFactory = new DefaultExtractorsFactory();
return new ExtractorMediaSource(videoUri, dataSourceFactory, extractorFactory, null, null);
}
defaultBandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter);
exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(ViewVideoNewPotriateFullScreen.this),
new DefaultTrackSelector(trackSelectionFactory), new DefaultLoadControl());
MediaSource datasource = buildMediaStore(url);
exoPlayer.prepare(datasource, true, true);
simpleExoPlayer.setPlayer(exoPlayer);
simpleExoPlayer.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
exoPlayer.setRepeatMode(Player.REPEAT_MODE_OFF);
exoPlayer.setPlayWhenReady(true);
exoPlayer.seekTo(getIntent().getLongExtra("position", 0));
//updateTimers();
exoPlayer.addListener(this);

How to play online video using ExoPlayer which is encrypted?

I want to play encrypted videos using ExoPlayer I am very new to ExoPlayer I don't know much about that. I found some links[https://stackoverflow.com/a/54247524/9789670] but those are not working fine.I need some help regrading this issue
Use this code for play video
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(null);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(mContxt, trackSelector);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(mContxt,
Util.getUserAgent(mContxt, "CloudExoplayer"));
Uri videoUri = Uri.parse(url);
MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(videoUri);
player.prepare(videoSource);
player.setRepeatMode(Player.REPEAT_MODE_ALL);
exoplayer.setPlayer(player);
exoplayer.requestFocus();
exoplayer.setPlayWhenReady(true);

exoplayer- automatic change of quality is not working (hls)

i have little problem with exoplayer. almost everything works fine when i try to play video from hls stream. hls stream contains 3 different sets of chunklists each for different bandwidth.
but hls adaptive streaming is not working and player works only with one chunklist and with slow internet connection is this solution unusable.
source code:
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
this.simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(getActivity(), trackSelector);
this.videoPlayer.setPlayer(this.simpleExoPlayer);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this.getActivity(), Util.getUserAgent(this.getActivity(), "appName"));
MediaSource mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(hlsUrl));
this.simpleExoPlayer.prepare(mediaSource);
this.simpleExoPlayer.setPlayWhenReady(true);
i tried to implement MediaSourceEventListener too and onDownstreamFormatChanged is called only once in the moment of player initialization.
thanks for any advices
The key here is you need to pass the same "bandwidthMeter" you passed in to AdaptiveTrackSelection.Factory to the dataSourceFactory too.
Only after these changes the Exoplayer does adaptive streaming as expected.
String userAgent = "XYZPLAYER";
DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, bandwidthMeter, httpDataSourceFactory);

Android Exoplayer 2 UDP Decoding issue

I'm new on ExoPlayer , i'm currently heading to use it to play Native Udp Stream ( From french digital Television : 1080p 5-10 mbps in Variable bitrate )
I manage to play some udp stream with some tests videos from http://jell.yfish.us/ on different devices .
I have make some different video decoding test with HLS and Udp Streaming with this code for UDP :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myactivity);
sufaceview = (SurfaceView) findViewById(R.id.surfaceView2);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl(
new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
15000, 60000, 2500, 6000);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
Uri uri =
Uri.parse
("udp://#239.192.2.2:1234");
final DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);
extractorsFactory = new DefaultExtractorsFactory();
DataSource.Factory udsf = new UdpDataSource.Factory() {
#Override
public DataSource createDataSource() {
return new UdpDataSource(null, 3000, 100000);
}
};
ExtractorsFactory tsExtractorFactory = new ExtractorsFactory() {
#Override
public Extractor[] createExtractors() {
return new TsExtractor[]{new TsExtractor(MODE_SINGLE_PMT,
new TimestampAdjuster(0), new DefaultTsPayloadReaderFactory())};
}
};
MediaSource videoSource = new ExtractorMediaSource
(uri, udsf, tsExtractorFactory, null, null);
player.setVideoSurfaceView(sufaceview);
player.prepare(videoSource);
player.setPlayWhenReady(true);
}
For HLS I just Change the MediaSource and the datasourceFactory :
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);
MediaSource videoSource = new HlsMediaSource
(uri, dataSourceFactory, null, null);
I Know Udpstreaming is not officialy supported by ExoPlayer but the UdpDataSource class seems to work well.
After all the test , i noticed video with a variable biterate like french DTT can't be decoded correctly but with Constatnt biterate video like Jell yfish the decoding process is perfect .
There is some coding improvement to make VBR video decoded correctly ?
Thank you by advance :)
Sorry for my bad english :)
Uri uri = Uri.parse("udp://#239.192.2.2:1234");
I think UDP is not a protocol - it's a transport, (like TCP). You can't use a tcp://host:port/ URL either.
Or does it work?

Categories

Resources