I am accessing a video link via the YouTube API thusly:
JSONObject(videoString).getJSONObject("entry")
.getJSONObject("media$group").getJSONArray("media$content")
.getJSONObject(0).getString("url");
Which gives me a link to a video such as:
rtsp://v7.cache5.c.youtube.com/CiILENy73wIaGQlXg0iXvlQ9SBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
I then try to play the video with:
mVideoView.setVideoURI(result);
final MediaController mediaController = new MediaController(mActivity);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
This works fine on my tablet running ICS but doesn't seem to work on GoogleTV, is there something I need to do specifically for GTV in this instance?
Logcat output:
04-30 14:03:41.212: D/MediaPlayer(1132): Couldn't open file on client side, trying server side
04-30 14:03:41.308: D/dalvikvm(1132): GC_CONCURRENT freed 862K, 13% free 8303K/9479K, paused 0ms+2ms
04-30 14:03:51.920: E/MediaPlayer(1132): error (1, -2147483648)
04-30 14:03:51.920: E/MediaPlayer(1132): Error (1,-2147483648)
04-30 14:03:51.920: D/VideoView(1132): Error: 1,-2147483648
I verified that VideoView playing YouTube RTSP video works on Google TV:
String vURL = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";
mVideoView = (VideoView)this.findViewById(R.id.myvideoview);
mVideoView.setVideoURI(Uri.parse(vURL));
final MediaController mediaController = new MediaController(this);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
Only thing I changed was parsing a different URL. Try this working URL in your code then.
Related
I am trying to play a video from the device on a VideoView. Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vView = (VideoView) findViewById(R.id.videoView);
mc = new MediaController(this);
vView.setMediaController(mc);
String new_emulator_path = "/storage/emulated/0/Download/testvid.mp4";
Uri uri = Uri.parse(new_emulator_path);
vView.setVideoURI(uri);
vView.requestFocus();
mc.show();
vView.start();
}
...
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/videoView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true" />
While using the same code on 5.1 it plays fine, but does not play in 4.3 and below. Following is the log extract:
04-30 00:28:09.141 2293-2293/com.ebook.video D/MediaPlayer: getMetadata
04-30 00:28:09.249 2293-2314/com.ebook.video E/MediaPlayer: error (1, -2147483648)
04-30 00:28:09.257 2293-2293/com.ebook.video E/MediaPlayer: Error (1,-2147483648)
04-30 00:28:09.257 2293-2293/com.ebook.video D/VideoView: Error: 1,-2147483648
I have seen many threads in regard to this error code, but could not comprehend any explanations.
EDIT: I have tried playing videos of different formats - mkv (H264 mpeg-4 AVC) , 3gp (H263), mp4 (H264 mpeg-4 AVC), flv (FLV1). Video with 3gp extension and H263 format plays fine, while others give the error message as mentioned above. Any ideas on how to resolve this ?
According to Documentation Android not support H265 before android 5.1
So I think you have issue with this. You can use ExoPlayer (Or better way ExoMedia simple wrapper around VideoPlayer & ExoPlayer).
BTW use following piece of code may helps you :
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
videoView.setVideoPath(YOUR_LOCAL_FILE_PATH);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
Log.i(TAG,"Hoooray");
}
});
videoView.start();
As I found out from your code you want to display video in emulator so first see this related post.
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 am making live tv channel streaming app.
But when i try to play the .sdp files in the android videoview it gives the error that "Sorry can't play this video".But it is playing .mp4 and .3gp videos successfully.
What should i do.I googled alot but in vain.
String VideoURL = "rtsp://pull.newclear.tv/live/livestream2_160p";
//"rtsp://pull.newclear.tv/live/livestream2_160p";
//.sdp links are also giving same error
//links of above type are not working
This is my code for videoview
MediaController mediacontroller = new MediaController(
VideoViewActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);
I tried to play a RTSP stream "rtsp://217.146.95.166:554/playlist/ch27yqcif.3gp" (this stream tested on KM Player and it is alive)
and also tried to play from "m.youtube.com" but not success. It give me an error "Sorry this video cannot be played" when the program run.
here is my code.
VideoView videoView = (VideoView) findViewById(R.id.myvideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse("rtsp://217.146.95.166:554/playlist/ch27yqcif.3gp");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
The app run and download data for sometime and give me the error "Sorry this video cannot be played"
when I try this http link it play well.
http://3gpvideos.org/wp-content/uploads/2012/13/Ishq%20Mein%20Ruswaa%20Full%20Song.3gp
I tried so many different RTSP links and formats but not successful.
What is the wrong with this code.
log details..
05-16 08:52:38.633: D/MediaPlayer(275): Couldn't open file on client side, trying server side
05-16 08:53:52.272: W/MediaPlayer(275): info/warning (1, 26)
05-16 08:53:52.272: I/MediaPlayer(275): Info (1,26)
05-16 08:53:52.313: E/MediaPlayer(275): error (1, -1)
05-16 08:53:52.313: E/MediaPlayer(275): Error (1,-1)
05-16 08:53:52.313: D/VideoView(275): Error: 1,-1
I wan't to open a .3gp video that is hosted on a remote server in a VideoView inside my app. The protocol used is RTSP. I keep getting this error:
04-07 19:26:32.528: E/MediaPlayer(7358): Unable to to create media player
04-07 19:26:32.536: W/VideoView(7358): Unable to open content: rtsp://v2.cache1.c.youtube.com/CiULENy73wIaHAk-BOiQ3AO9gBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp
04-07 19:26:32.536: W/VideoView(7358): java.io.IOException: setDataSource failed.: status=0x80000000
The stream is working and the codec should be supported. Can't locate the problem. I've tried it on a Sony GTV box and on a ICS tablet.
This is the code I'm using:
videoview.setVideoURI(Uri.parse(viduri));
MediaController mc = new MediaController(PlayerActivity.this);
videoview.setMediaController(mc);
videoview.requestFocus();
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
progressBar.setVisibility(View.GONE);
videoview.start();
}
});
Does anyone have experience with the same issue? Any solutions? The error message isn't very helpful...
What I see is that this stream can't be found. Are you obtaining this Youtube video using YouTube Data API?