I'm trying to play a video using a url but it's not working. It always give me error on screen as Can't play this video.
I'm using below snippet:
val uri: Uri = Uri.parse(it.url)
binding.videoView.setVideoURI(uri)
val mediaController = MediaController(activity)
mediaController.setAnchorView(binding.videoView)
mediaController.setMediaPlayer(binding.videoView)
binding.videoView.setMediaController(mediaController)
binding.videoView.setOnPreparedListener { binding.videoView.start() }
Logcat Error:
E/MediaPlayerNative: error (1, -1015)
E/MediaPlayer: Error (1,-1015)
I'm getting the YouTube url mostly. Thanks in advance.
Related
I'm trying to load video from my S3 AWS service.
The problem is that every time I try to load video, I'm getting:
D/MediaPlayer﹕ Couldn't open file on client side, trying server side
E/MediaPlayer﹕ error (1, -2147483648)
E/MediaPlayer﹕ Error (1,-2147483648)
D/VideoView﹕ Error: 1,-2147483648
I don't know if it's problem with permissions? This is my Android Code:
AWSCredentials myCredentials = new BasicAWSCredentials("my-key", "secret-key");
AmazonS3 s3client = new AmazonS3Client(myCredentials);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest("-", "AndroidCommercial.3gp");
objectURL = s3client.generatePresignedUrl(request);
videoview = (VideoView) findViewById(R.id.videoView);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mediaCtrl;
mediaCtrl = new MediaController( MainActivity.this );
mediaCtrl.setMediaPlayer(videoview);
videoview.setMediaController(mediaCtrl);
Uri clip = Uri.parse(String.valueOf(objectURL));
videoview.setVideoURI(clip);
videoview.requestFocus();
videoview.start();
I'm not sure if it's problem with AWS or my APP... I've created user with AmazonS3FullAccess policy. I can download that file with AWS chrome extension. Can anyone help me?
Best Regards, Mateusz
I want to play WVM videos on my Application. I am using WideWine DRM plugin for that.
The Videos getting License successfully and running fine,
But When I move the SeekBar of MediaController from current position to any position, It throws a MediaPlayer error sometime.
The error is like :
MediaPlayer error (260, -2001)
What are the actual cause for this error ?
I have used this code to start video :
wv = new WidevineDrmHandler();
wv.initialize(MainActivity.this);
wv.requireLicence(url, handler2, false);
mVideoView.setVideoURI(Uri.parse(url));
mVideoView.start();
I am getting error while playing video from asset folder and raw folder.
MediaPlayer error (1, -2147483648)
VideoView error 1, -2147483648.
I tried from asset folder as.
private String SrcPath = "file:///android_asset/aaa.mp4"; //also tried aaaa.mp3
VideoView vv = (VideoView)findViewById(R.id.videoView1);
vv.setVideoPath(SrcPath);
MediaController controller = new MediaController(this);
controller.setAnchorView(vv);
vv.setMediaController(controller);
vv.requestFocus();
vv.start();
and for raw folder i used URI as :
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4");
vv.setVideoURI(video);
I got the same error message in both cases.
You can use software like avinaptic2 to get the video encoding information and make sure it matches the supported media formats in android.
A common problem I find is that videos are encoded with the wrong profiling. H.264 videos need to be encoded with Baseline level 3 or under to be played without errors or artifacts in Android.
I found the solution as I am able to play video on virtual device.
I replaced the line
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4");
with
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/"+R.raw.aaa);
And its working
Using R.raw works fine but in some cases I still get the same error. Fortunately I found the solution to my problem: I had to call videoView.start() inside onPrepare().
You can check the correct answer here:
Android: 'Can't play this video'; MediaPlayer & VideoView Error 1 -38
I am working on an app which stream youtube videos.
Here is my code snippet :
MediaController mediaController = new MediaController(PlayVideo.this);
mediaController.setAnchorView(videoView_Video);
mediaController.setMediaPlayer(videoView_Video);
Uri videoUri = Uri.parse(url);
videoView_Video.setMediaController(mediaController);
videoView_Video.setVideoURI(videoUri);
videoView_Video.requestFocus();
videoView_Video.start();
mediaController.show();
My URI:
videoUri = rtsp://v2.cache8.c.youtube.com/CiILENy73wIaGQm-LZitWsUGKxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
Now I Am getting an error as below:
1. http youtube = false, scheme = rtsp
2. Couldn't open file on client side, trying server side
3. Error (1,-2147483648)
4. Error: 1,-2147483648
And a dialog with a message :
Please suggest any answer to overcome this.
Use the proper API instead of manually parsing and finding videos.
https://developers.google.com/youtube/android/player/
you just import the proper YouTubeVideoPlayer and things work fine.
ps.: I don't suggest using this in a ViewPager, I only had problems with that.
Google has a YouTube Android Player API that enables you to incorporate video playback functionality into your Android applications. The API itself is very easy to use and works well. For example, here is how to create a new activity to play a video using the API.
Intent intent = YouTubeStandalonePlayer.createVideoIntent(this, "<<YOUTUBE_API_KEY>>", "<<Youtube Video ID>>", 0, true, false);
startActivity(intent);
See this for more details.
I am trying to open a video in a videoView using an url.
Here are the code i use:
public void playVideo(){
String path= "http://s3.amazonaws.com/yendis_development/uploads/container/content/4fd79353c83b7260e6000003/3.mpg";
String path1="http://commonsware.com/misc/test2.3gp";
Uri uri=Uri.parse(path);
VideoView video=(VideoView)findViewById(R.id.video_view);
video.setVideoURI(uri);
video.start();
}
When i use "path1", my VideoView get the video and play it fine.
but when i use "path", i don't get the video and i got a dialog saying "Sorry, this video cannot be played".
Why the webview worked for the path1 and not for path? You can open path and path1 in the navigator so you can see videos' test.
When path, In my logcat, i got this message (error):
08-11 17:08:47.411: E/MediaPlayer(10064): error (1, -2147483648)
08-11 17:08:47.411: E/MediaPlayer(10064): Error (1,-2147483648)
08-11 17:08:47.411: D/VideoView(10064): Error: 1,-2147483648
Thanks