i am working on an app, in which i want to play a video intenting ACTION VIEW from URL receiving from WEB SERVER, i am getting unsupportable file format. my code is
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
videostring = ib.getVideostring();
Uri data = Uri.parse("file:///https://" + videostring.get(0));
intent.setDataAndType(data, "video/*");
context.startActivity(intent);
Change Uri data = Uri.parse("file:///https://" + videostring.get(0));
to
Uri data = Uri.parse("https://" + videostring.get(0));
Related
I am trying to create a intent which will call a mxplayer intent and vlc player intent . This intent will contain live video link and user agent . I added the url using intent.setData() but how to add the user agent header ?
Code :
String packagename = "com.mxtech.videoplayer.ad";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(packagename);
intent.setData(Uri.parse(now.video_url));
//add the user agent header here
// now.user_agent contains the agent link
context.startActivity(intent);
Also how to do it in vlc player , I didn't find anything in their android-api with user-agent
My try for vlc:
String packagename = "org.videolan.vlc";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(packagename);
intent.setData(Uri.parse(now.video_url));
intent.putExtra("user-agent",now.user_agent);
//tried these too , doesn't work
//intent.putExtra("http-user-agent",now.user_agent);
//intent.putExtra("User-Agent",now.user_agent);
//String[] headers = {
// "http-user-agent", now.user_agent
// };
//intent.putExtra("headers",headers);
context.startActivity(intent);
From looking at their API I added this and it worked
String[] headers = {
"User-Agent", now.user_agent
};
intent.putExtra("headers",headers);
context.startActivity(intent);
Didn't find anything for VLC till now
I am having webservice which has a String URL response, URL could be of .PNG and .PDF I don't want to download image and pdf files from that url I want to show them on default viewer i.e. if i click to view image button then it should open image url to any default photo viewer and if i click to view pdf button then it should open pdf in default pdf viewer.
Please help Thanks in advance.
File file = new File(url);
MimeTypeMap myMime = MimeTypeMap.getSingleton();
Intent newIntent = new Intent(Intent.ACTION_VIEW);
String extension = file.getName().substring(file.getName().indexOf(".") + 1).toLowerCase();
String mimeType = myMime.getMimeTypeFromExtension(extension);
newIntent.setDataAndType(Uri.fromFile(file), mimeType);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(newIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(MasterPlan_Activity.this, "No handler for this type of file.", Toast.LENGTH_LONG).show();
}
The basic concept here is opening an app that can handle your resource (JPEG or PDF). So, you need to request an Implicit Intent with the data URI that needs to be shown.
You can use intent with specific filter to achieve that, as shown below
Image:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media/16"))); /** replace with your own uri */
Pdf:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pdf_url));
startActivity(browserIntent);
or
private static final String googleDocsUrl = "http://docs.google.com/viewer?url=";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl + url), "text/html")
I need to play a mp4 video in my app, bat I want to use intent. Is this possible?
private void startTrailer(){
Uri contentUri = Uri.parse("android.resource://" + pkgName + "/" +R.raw.v01_homem_ferro_3);
Intent intent = new Intent( Intent.ACTION_VIEW );
intent.setDataAndType( contentUri, "video/mp4" );
context.startActivity( intent );
}
Exception: No Activity found to handle Intent.
Somebody had this issue before. Check these links and see if they give you a good starting point to solve the problem:
Android intent for playing video?
How to play a video (.mp4) from assets or raw folder with the video intent?
Please try this, Here strMyVideo is my filepath,
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(strMyVideo));
intent.setDataAndType(Uri.parse(strMyVideo), "video/mp4");
activity.startActivity(intent);
I want to upload video on you-tube and i am uploading video using this code but the problem is that whenever i click the button from my app then i have to select you-tube from list view of email,Bluetooth,you-tube,etc..
So i want the permanent solution for this that whenever i click a button from my app it automatically moves to you-tube without showing list view.
So, this is my code which i used to upload video over you-tube.
**ContentValues content = new ContentValues(4);
content.put(Video.VideoColumns.TITLE, "My Test");
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis() / 1000);
content.put(Video.Media.MIME_TYPE, "video/mp4");
content.put(MediaStore.Video.Media.DATA, outputFile);
ContentResolver resolver = getContentResolver();
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,content);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/*");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share using"));**
This might help you,
String url = "http://youtu.be/mo1DmO9JH3Y"; // Your Url here..
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://"+url));
activity.startActivity(intent);
Intent intent1 = new Intent(
android.provider.MediaStore.INTENT_ACTION_MUSIC_PLAYER)
.setData(selectedImageUri);
i want to play a media file using android default media player but its not working in devices showing
ActivityNotFoundException
.can any one help me to correct it.i am stuck here
String extension = MimeTypeMap
.getFileExtensionFromUrl(selectedImagePath);
String mimeType = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(extension);
Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
mediaIntent.setDataAndType(Uri.parse(selectedImagePath),
mimeType);
startActivity(mediaIntent);
I used this code and i got my output.
Maybe this will help you. The following is the piece which I use and it works fine. Pass the url to your default media Player and from there it will take care of it.
Uri myUri = Uri.parse( //your url);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(myUri, "audio/*");
startActivity(intent);