Android VideoView Error: 1,-19 - android

Can anyone tell me how to use videoview to play mp4 url. I have written the code which is giving me error in my logcat as:
08-05 04:37:35.978: D/MediaPlayer(1693): getMetadata
08-05 04:37:37.918: E/MediaPlayer(1693): error (1, -19)
08-05 04:37:37.928: E/MediaPlayer(1693): Error (1,-19)
08-05 04:37:37.928: D/VideoView(1693): Error: 1,-19
I am using the videoview java code as:
public class VideoPlayerActivity extends Activity {
#SuppressLint("NewApi")
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_play);
VideoView videoView = (VideoView) findViewById(R.id.videoview_video);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
System.out.println(mediaController);
Uri video = Uri.parse("http://192.168.1.100/Android/jum.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
System.out.println("View:"+videoView);
videoView.start();
}
}
I have made the video as H 264 compressed format but also i am not able to watch and listen the video
in the android app
Error in the android emulator is as shown below:

Did you set the internet permission in Manifest file?
Are you sure its http and not https ?
Are you running a version earlier than 3.1 ? If so, is the audio encoding through AACP?
These are some of the reasons that could give that error.

Related

"Can't play this video" Error using URL with VideoView and Mediacontroller

So I'm trying to do my homework, but the teacher's given me 0 information about this. There is an example of how to play a video from a file in the res/raw folder, but there's nothing about online URLs. Please help me, I just want a simple player. I'll attach a picture detailing exactly what is up. I'll also add the code, since it's not that much and I really have no clue what could be wrong. Error says this:
W/MediaPlayer: Couldn't open http://techslides.com/...
java.io.FileNotFoundException: No content provider: http://techslides.com/demos/sample-videos/small.mp4
And this is the code:
VideoView video;
String url = "http://techslides.com/demos/sample-videos/small.mp4";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
video = (VideoView) findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(mc);
video.setVideoPath(url);
video.setMediaController(mc);
video.start();
}
I will finally add to this that I've tried several different URLs, including some https ones and some http.
EDIT:
So, I tried fixing it and it ended up looking like this:
video = (VideoView) findViewById(R.id.videoView);
final MediaController mc = new MediaController(this);
mc.setAnchorView(mc);
video.setVideoPath(url);
video.setMediaController(mc);
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){
#Override
public void onPrepared(MediaPlayer mp){
video.start();
}
});
But it still gives me the same error when the emu is open. "Can't play this video". On the other hand, I got a bunch of new errors:
E/MediaPlayerNative: error (1, -2147483648)
E/MediaPlayer: Error (1,-2147483648)
D/VideoView: Error: 1,-2147483648
I'm not really familiarized with this technology, and the teacher hasn't given us any notions whatsoever as to what should or shouldn't be in the code for it to work. Just an example of a locally stored video playing in Android Studio with VideoView... that doesn't work when applied to online URLs.
So I've ended up fixing it myself. The problem wasn't in the code, for anyone wondering I've ended up using this simple format:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
video = (VideoView) findViewById(R.id.video);
Uri uri = Uri.parse("http://techslides.com/demos/sample-videos/small.mp4");
video.setMediaController(new MediaController(this));
video.setVideoURI(uri);
video.requestFocus();
video.start();
}
The problem was the AVD itself. I had a Pixel 1 running Android 9, and that for some reason didn't work. I've installed a Nexus 5 with Oreo and it works flawlessly.
This may help you
VideoView simpleVideoView = (VideoView) findViewById(R.id.simpleVideoView); // initiate a video view
// perform set on prepared listener event on video view
simpleVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
// do something when video is ready to play, you want to start playing video here
}
});
Try to start video only when its fully ready to play. Since mp4 will take some time to download.. so it might be in inconsistent state when you started video.
Hope this will help.

Make Video Streaming URL secure from Logging in Logcat

Currently I'm trying to simply stream a Video from some link this way:
try {
videoView = (VideoView) findViewById(R.id.videoView);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.setVideoPath("http://some.link/some_video.mp4");
loadingProgress.show();
videoView.requestFocus();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
loadingProgress.dismiss();
videoView.start();
}
});
} catch (Exception e) {
e.printStackTrace();
}
Everything is going OK, but I want to make that URL (i.e. http://some.link/some_video.mp4) secure. I mean user won't be able to download this video.
The problem is: before loading this video, the logcat is
displaying log like this:
my.app.package.name W/MediaPlayer: Couldn't open http://some.link/some_video.mp4: java.io.FileNotFoundException: No content provider: http://some.link/some_video.mp4
I have noticed:
Even the code is not going into CATCH block.
Made SIGNED App, but that LOG is still appearing.
Those logs are built into the framework MediaPlayer class. The only way I know of to remove it is to take the MediaPlayer code from AOSP, copy it to a class in your app, remove all the log statements, and use that instead of the Android MediaPlayer class.

Playing video in android directly from server

I am currently playing a video in andriod from the url http://daily3gp.com/vids/747.3gp
its working successfully.
But here i need to play that url through server, please let me know how to play.
Find the code below:
CODE
public class Activity3 extends Activity {
private VideoView videoView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main2);
videoView = (VideoView)this.findViewById(R.id.videoView_surface_1);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://daily3gp.com/vids/747.3gp"));
videoView.requestFocus();}}
Thanks for your Time!!
You have to call videoview.start() after this call only videoview will start playing video.

open udp multicast video stream on android

How can I open a udp multicast video stream on android ?
I tried this code:
public class androidActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.videoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse("udp://224.1.1.1:1234");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
but it doesn't work.
Android doesnt support UDP for audio and video playback.
see http://developer.android.com/guide/appendix/media-formats.html
You can use RTP over UDP.
This is with RTSP setup via TCP.
I do this with stock android rom, no third party apps required.
Stagefright framework.

How to stream video in Android Emulator?

I am newbie in Android, and I tried a lot with my code to stream video in emulator, but I am getting exception "Sorry The application Hellovideodemo(...) has stopped unexpectly.
Here is the code:
public class HelloVideoDemo extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri
.parse("http://dev2010.excoflare.com/zencart/abhishek/BlackBerry_Social_Meeting/av/testing.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
Any help will really be appreciated. Thanks.
Have you declared the Internet permission as a child of the Android Manifest?
<uses-permission android:name="android.permission.INTERNET" />
setcontentview that function should have r.id.videoview not main try i guess it should work

Categories

Resources