问题
Please have a look at the following code
private class IntroVideoHandler implements OnClickListener
{
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource("http://www.youtube.com/watch?v=Cb7QJwQ58T0");
mp.prepareAsync();
mp.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Here, I am unable to play the youtube video either in simulator or phone. I get the following error
08-22 14:34:47.176: E/MediaPlayer(471): start called in state 4
08-22 14:34:47.176: E/MediaPlayer(471): error (-38, 0)
08-22 14:34:47.306: E/MediaPlayer(471): Error (-38,0)
08-22 14:34:56.426: E/MediaPlayer(471): error (1, -2147483648)
08-22 14:34:56.426: E/MediaPlayer(471): Error (1,-2147483648)
Why is this?
回答1:
see this API
And
You can not play youtube video directly in video view this way.. you have below option to play it.
1) load this url in webview
2) pass youtube video id to youtube application.
3) get RTSP url from video id and play in videoView
来源:https://stackoverflow.com/questions/18375930/unable-to-play-youtube-videos