how to hide url details in default player in android - android

I call the default audio player using intent. Its playing correctly, but want to hide details of playing URL is display in top of the play.its my coding
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
mediaIntent.setDataAndType(Uri.parse(url), mimeType);
startActivity(mediaIntent);

This can't be achieved with with such an implicit intent like that. This is because you have no control over the UI that is being used to play the content. In order to solve your problem, You must play the file using a specific class available in the framework.

Related

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.

Start default music app in Android and play file

I have app where I have url of media file.
I wish if I could start Music and Video app and play file.
Is there any chance to do that.
I dont want to write my own media player app.
Create an ACTION_VIEW intent with the path to your media file and include the type of media you want to play.
String audioPath = "path/to/audio.mp3";
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
// set the data and type, for movies this would be video/*
intent.setDataAndType(Uri.parse(audioPath), "audio/*");
getContext().startActivity(intent);
You don't have to set the type, but I would suggest doing so. Setting the type will limit the activities to activities that know how to handle the given type.

Android how to play video using VLC Player?

I have app for play video in android like as
https://play.google.com/store/apps/details?id=com.vlcforandroid.vlcdirectprofree&hl=en
I want to integrate this app in my app. I have Url for video Streaming and i want to open this video in this app(Vlc Direct), Any idea?
I open this app using:
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.vlcdirect.vlcdirect");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
But how it start with video streaming, Or any other Player for video Streaming?
More like,
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName("com.vlcdirect.vlcdirect", "com.vlcdirect.vlcdirect.URLStreamerActivity"));
i.putExtra("url", url);
startActivity(i);
Which supposes that the component, activity, and payload are as shown, and also that the activity is explicitly or implicitly exported -- I don't know the actual values, or if the activity is exported. vlcdirect doesn't document this, but you can
ask the developer, or
view the log as you stream from a URL within that app, to identify the component and activity; dedex and decompile the .apk, to confirm the payload; duplicate payload classes, if necessary; give up and fume after the developer ignores you, if the activity is not exported.
Ideally you would broadcast a "view the stream from this URL" intent, and vlcdirect or any other suitable app would pick it up, but I don't know if vlcdirect or any other app respond to such.
VLC needs to be explicitly told the type:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("org.videolan.vlc.betav7neon");
i.setDataAndType(Uri.parse("http://ip:8080"), "video/h264");
startActivity(i);
i.e. just "video/*" wouldn't work for me
Previous answers didn't work me. After a bit of searching I found the official docs here.
Basically, here it is:
int vlcRequestCode = 42; //request code used when finished playing, not necessary if you only use startActivity(vlcIntent)
Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4"); //your file URI
Intent vlcIntent = new Intent(Intent.ACTION_VIEW);
vlcIntent.setPackage("org.videolan.vlc");
vlcIntent.setDataAndTypeAndNormalize(uri, "video/*");
vlcIntent.putExtra("title", "Kung Fury");
vlcIntent.putExtra("from_start", false);
vlcIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt"); //subtitles file
startActivityForResult(vlcIntent, vlcRequestCode);
You can remove unnecessary parts for you.

Play Video on the Browser

I tried to open the video from url with Intent.ACTION_VIEW, and it was successful.
But, the problem is, after the browser appeared for a second and it's automatically minimize and the front is the activity on the apps.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("the url of the video with format .m3u8");
intent.setData(data);
startActivity(intent);
I'm expecting exactly the same way when i put the URL into the browser manually, but without minimize the browser when it has already been launched.
Need some flags? grateful for any response and suggestions.
I bet that the browser is just quitting as a result of an inability to display the content. If you plug in the video url to the browser manually, does it work? What is the filetype of the content you are trying to display?
Have you tried explicitly setting data type by using setDataAndType(Uri data, String type) where mime type is "audio/x-mpegurl" (the full mime type is "audio/x-mpegurl; charset=UTF-8"). You might have some switch statement to check URL user has clicked to force type in case link points to ".m3u8".

Categories

Resources