Android Network Error while playing mp4 files - android

I try to play a mp4 video from url sending the video intent - intent.setDataAndType(pathuri, "video/*"); but I get the dialog Can't play the video due to android network error.I have the internet permission in manifest file and the url of the video is good.Also I cant play the video in my app using videoview for video urls. Please help.
Intent in=new Intent();
Uri vidUri = Uri.parse(feedob);
in.setDataAndType(vidUri, "video/*");
Log.e(TAG, "On CLICK, VIDEO URL " + feedob);
startActivity(in);
Now the feedob is https://scontent.cdninstagram.com/t50.2886-16/12796233_1731088863793436_102464613_n.mp4

The process is not allowed to run in the main thread, so you need a second one. Would be helpfull if you post the code + error log

Related

Playing raw audio file in default music player

My App is having audio files in raw folder. Now whenever app gets launched these audio files should play using default music player. I tried below code App is crashing with "No Activity found to handle this intent".
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("companion.harman.com.ceshuclient/res/raw/fav.mp3"), "audio/*");
startActivity(intent);
The same audio files can be played using "MediaPlayer" object but that is not what exactly I'm trying to acheive.
Any sample code or links can be helpful.
Thanks in Advance.
Please try the following (Where mp3file is the name of the file in the raw folder without extension. Use only lowercase characters, please):
MediaPlayer player = MediaPlayer(this,R.raw.mp3file);
player.prepare();
player.start();
player.stop();
player.reset();
player.release();
player = null;
Here is the link of demo source code to play mp3 File

Android (Intent.ACTION_VIEW) not recognizing on Mi device for mimeType video/mp4

I have taken a video from camera which gets saved in camera/DCIM location on sdCard
Now my app takes the local path of the video and try playing the video using default video player with below code
private void playVideo(String path) {
Uri videoUri = Uri.parse(path);
Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setDataAndType(videoUri, "video/*");
if (videoIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(videoIntent, null));
}
}
Now issue is the video doesn't play with a toast "Media view not found" on Mi devices + a few other.
But the same video plays through through selecting video from FileManager applications.
So I guess the issue is not with VideoPlayer. INSTEAD I think it's the issue with what mimeType is getting shared to the player. But thats just my assumption.
Anyone faced a similar issue, I need help as this issue is eating up my time.
Thanks
/storage/emulated/0/DCIM/Camera/VID_20160113_130138.mp4 is not a valid string representation of a Uri. A Uri needs a scheme.
Presumably, once upon a time, you had a File object for this. Use that, and Uri.fromFile(), instead of Uri.parse(). Or, use Uri.fromFile(new File(path)). This will give you the proper scheme setup.

how to play sdp file in android?

I am using following code to play video for .3gp format and it works fine but I am facing problem while playing .sdp url.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("rtsp://stream.the.sk/live/musicbox/musicbox-3m.3gp"));
startActivity(intent);
I need to play rtsp://ss1c6.idc.mundu.tv:554/prf0/cid_29.sdp format but it not work. Please help me. I tried to play it with VLC and MX Player.
Try this code in onCreate function. It will work i think.
VideoView view=new VideoView(this);
setContentView(view);
view.setMediaController(mediaController);
view.setVideoURI(Uri.parse("rtsp://ss1c6.idc.mundu.tv:554/prf0/cid_29.sdp"));
view.start();

Play youtube video from URL in android

I want to play youtube video in my application. I am getting video URL from SAX Parsing. My question is how to play video from URL in VideoView, not in Webview or Browser.
I tried this code :
Intent lVideoIntent = new Intent(null, Uri.parse("VIDEO URL"));
startActivity(lVideoIntent);
It is displaying one popup screen with 'Internet' and 'YouTube' options. I want to play the video directly in youtube.
Please let me know your thoughts. Any code or any example is highly appreciated.
you can try below code for direct play in Youtube application.
Intent videoClient = new Intent(Intent.ACTION_VIEW);
videoClient.setData(Uri.parse("https://www.youtube.com/watch?v=EwSdmxyayx0&feature=youtube_gdata"));//you can try here your own video url
videoClient.setClassName("com.google.android.youtube", "com.google.android.youtube.PlayerActivity");
try{
startActivity(videoClient);
}catch(ActivityNotFoundException excp){
try{
videoClient.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoClient);
}catch(ActivityNotFoundException exc){
exc.printStackTrace();
}
}
String videoUrl = "http://www.youtube.com/watch?v=cxLG2wtE7TM"
//split video url and get value of v ie cxLG2wtE7TM
String videoId = "cxLG2wtE7TM";
String action = Intent.ACTION_VIEW;
Uri uri = Uri.parse("vnd.youtube:" + videoId);
Intent videoIntent = new Intent(action, uri);
startActivity(videoIntent);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("video url"));
VideoActivity.this.startActivity(i);
It is displaying one popup screen with 'Internet' and 'YouTube'
because the ACTION_VIEW intent is written both in default browser and Youtube application. that's why whenever it catches the URL the Browser opens and whenever the Youtube URL is opened Both the browser and Youtube app.
I want to play the video directly in youtube
Take the embed link of Youtube video and set intent it will play the video.
ex:-http://www.youtube.com/embed/srMFb6zpx2Y

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