0

URL からビデオをストリーミングする Android アプリを開発しようとしています。しかし、次のエラーが発生します。

@Override
public void onClick(View v) {

    Log.d("TAG", "on Click");
    System.out.println("on Click");
    // TODO Auto-generated method stub
    if(v==play)
    {
         if( mp.isPlaying()==false && mp!=null)
         {

                  mp.start();
         }
    }
    if(v==stop)
    {
        mp.stop();
        mp.release();
        mp=null;
    }
    if(v==sd)
    {
        Log.d("TAG", "Loading the video file");
        //path="C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv";
        //path="http://10.17.68.18:8080/stream";
        path = "http://www.youtube.com/watch?v=wBGIoxvEakw";

        try{

            mp=new MediaPlayer();
            mp.reset();
            mp.setDataSource(URLEncoder.encode(path,"UTF-8"));
            mp.prepareAsync();
            mp.setOnPreparedListener(new OnPreparedListener(){
                public void onPrepared(MediaPlayer mp) {
                    Log.d("TAG", "Playing the video file");
                    mp.start();
                }
            });

            //mp.start();
        }
        catch( Exception e)
        {
            System.out.println(e);
            Toast.makeText(this,e.toString(),Toast.LENGTH_LONG)
            .show();
        }
    }

}

エラーログ:

02-09 20:44:11.746: W/MediaPlayer(2807): info/warning (1, 26)
02-09 20:44:11.746: E/MediaPlayer(2807): error (-4, -4)
02-09 20:44:11.777: I/MediaPlayer(2807): Info (1,26)
02-09 20:44:11.785: E/MediaPlayer(2807): Error (-4,-4)
02-09 20:49:50.815: W/KeyCharacterMap(2807): No keyboard for id 0
4

2 に答える 2

0

Given Youtube URL doesn't provide Media stream, just youtube webpage.

If you want to play youtube content in Android platform, consider to use Youtube Android API.

https://developers.google.com/youtube/android/player/

于 2013-02-10T04:06:48.293 に答える