I'm getting java.net.ProtocolException
for some of the videos. This is how passing the URL to videoview
. Did anyone face this before?
videoview.setVideoURI(videourl);
I'm getting java.net.ProtocolException
for some of the videos. This is how passing the URL to videoview
. Did anyone face this before?
videoview.setVideoURI(videourl);
After several rounds of debugging, I figured out it is due to the unsupported video format. Android default Mediaplayer or Videoview doesn't support all formats, for eg: MOV.
By using the exoplayer you can overcome this issue. Pls chk the supported formats here.
private void initializePlayer(String downloadedFile) {
player = ExoPlayerFactory.newSimpleInstance(this);
player.addListener(eventListener);
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "Player"));
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new ExtractorMediaSource(streamurl,
dataSourceFactory, extractorsFactory, null, null);
player.prepare(videoSource, false, false);
player.setPlayWhenReady(true);
videoview.setShutterBackgroundColor(Color.TRANSPARENT);
videoview.setPlayer(player);
videoview.requestFocus();
}
@Override
public void onLoadingChanged(boolean isPlaying) {
Log.d(TAG,"videoplaying onLoadingChanged::"+isPlaying);
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_BUFFERING){
//show progressbar
} else {
//dismiss progressbar
}
}
}