Display subtitle with Android Media Player? - android

I am using this snippet to open a video using default Android Video Player:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://my.video/link.mp4"), "video/mp4");
startActivity(intent);
Now I want to display subtitle on the video, my subtitle is provided with a url, example http://my.subtitle/link.srt. I think there would be something simple like this:
intent.putExtra("subtitle", "http://my.subtitle/link.srt");
But it doesn't seem to be simple like that.
Could anyone show me how to do it? Thanks a lot.

Related

Is there any way to use native android player for videos?

I'm developing an android app and I wanted to do something like that:
I have simple button and when I press it, the android native player pops with video up
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse(Path to video file);
intent.setDataAndType(data, "video/mp4");
startActivity(intent);
use this if you don't want to use videoview

How can i read streaming/video from this intent?

I have read on the internet from other discussions on stackoverflow that this is the best way to view a streaming stream without immowing dependencies external to the application:
//videoURL = 'url:3030/stream'
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(videoURL));
startActivity(intent);
Unlike other intentions that link to a class that shows their content, however, this intent shows nothing.
How can I view the contents of this intent?
Simply use a video view and set the Uri to the uri of the stream using the VideoView.setUri(uri) method.
This tutorial talks about this:
https://code.tutsplus.com/tutorials/streaming-video-in-android-apps--cms-19888
However if you want to stream a live video or some other format not supported by VideoView you can use the vlc-sdk.
Read into this:
http://www.truiton.com/2015/03/stream-rtmp-live-android/

How to open video file with custom title

I want to open video file and set the previewed title in video player with a different title than the file name (which is used by default).
String videoFile = "Video file url / path";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(videoFile), "video/mp4");
// Is there an extra to set the previewed video title?
mMainActivity.startActivity(intent);
There is no documented extra for ACTION_VIEW that would offer this, and third-party video players would not have to honor it anyway. You are welcome to implement your own video player in your own app if you wish to control the title.

disabling video controls in ACTION_VIEW

Hi My Question is want to disable or not to show the video controls if i use ACTION_VIEW for any videos. Do i need to specify any extras for Intent or is there any proper way to achieve this
below is the code for reference
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(appnamesArray[arg2]));
Any Sample links or code helps me a lot
Thanks in Advance
EDIT:
As i understood that action_view starts the default player or user selected player so the controls goes to player and intent has no control to hide it for that i used videoview to show the video from url
VideoView videoView = (VideoView) new VideoView(getApplicationContext());
MediaController mediaController = new MediaController(MainActivity.this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(appnamesArray[arg2]);
videoView.setMediaController(null);
videoView.setVideoURI(video);
videoView.start();
setContentView(videoView);
please update me if any one can able to succeed this by doing the ACTION_VIEW itself
If you use the view intent it will have option to open video in all the players that support it. So even if some of the players support hiding controls other might not.
Best solution is to have your own video view.

android: using default video player

I have an application that plays video files.
I have been using code for using Videoview and starting the Videoview manually to play video files. However, I just wanted to know if I can use the default media player or video player of android rather than creating or using the VideoView to play the file..
Please make comments if the question is not clear.
Thanks alot
Sure - just use an Intent with the file Uri.
File file = new File("fileUri");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);

Categories

Resources