【问题标题】:Having error message (Sorry this video can't play) to play online video in VideoView在 VideoView 中播放在线视频时出现错误消息(抱歉此视频无法播放)
【发布时间】:2015-07-12 11:29:15
【问题描述】:

谁能给我建议,为什么这段代码不起作用.....

public class VideoActivity extends Activity {

/** Called when the activity is first created. */
String Link="http://www.veoh.com/watch/v18571861xWT9d7yF";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    VideoView videoView = (VideoView) findViewById(R.id.videoView1);
    MediaController mc = new MediaController(this);
    mc.setAnchorView(videoView);
    mc.setMediaPlayer(videoView);
    Uri video = Uri.parse(Link);
    videoView.setMediaController(mc);
    videoView.setVideoURI(video);
    videoView.start();
    }
}

【问题讨论】:

    标签: android


    【解决方案1】:

    尝试使用以下代码....

    它对我有用....与您的代码非常相似,除了 mc.setMediaPlayer(videoView); 此外,我认为这与您尝试播放的 3gp 视频的尺寸有关。 我的代码中的 Vidoe URL 在 vi​​deoview 上运行良好。 ` package ramit.android.videoexample;

    import android.app.Activity;
    import android.net.Uri;
    import android.os.Bundle;
    import android.widget.*;
    public class video extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        VideoView v1= (VideoView)findViewById(R.id.videoView1);
        MediaController mc = new MediaController(this);
    
    
        mc.setAnchorView(v1);
        Uri video = Uri.parse("http://www.jsharkey.org/downloads/dailytest.3gp");
        v1.setMediaController(mc);
        v1.setVideoURI(video);
        v1.start();
    }
    }`
    

    【讨论】:

      猜你喜欢
      • 2011-09-18
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多