2013-03-02 82 views
1

我目前正在使用我的Android應用。到目前爲止,我已經到了需要我的應用程序的地步。爲用戶查看一些視頻 最初我想將我的視頻存儲在我的服務器中(當前是本地的,但稍後可能會移動),然後我找不到如何操作的方法,因此我選擇從YouTube頻道我是爲此目的而制定的「我認爲它會看起來更瑣碎。」任何方式!在Android中運行視頻問題

到目前爲止,我運行我的應用程序。在我的手機因爲我讀了模擬器不能運行視頻。它運行在我的手機上,但有一些問題。

1 - 我不得不暫停視頻ASA視頻佈局彈出,等待視頻緩衝或類似的東西,否則我得到了錯誤消息「該視頻無法播放」

2-以後當它加載時,它自己開始,即使我沒有按下開始按鈕。 3-視頻拍攝屏幕的上半部分,底部有白色空間,兩半之間有空隙。

4-視頻不清晰,因爲我可以在筆記本電腦或YouTube應用程序中查看它。

這裏是我的.java代碼

public class video extends Activity { 


String SrcPath = "rtsp://v8.cache3.c.youtube.com/CjYLENy73wIaLQltaP8vg4qMsBMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYOL6qv2DoMPrUAw=/0/0/0/video.3gp"; 

/** Called when the activity is first created. */ 

public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.video1); 
VideoView myVideoView = (VideoView)findViewById(R.id.vview); 
myVideoView.setVideoURI(Uri.parse(SrcPath)); 
myVideoView.setMediaController(new MediaController(this)); 
myVideoView.requestFocus(); 
myVideoView.start(); 
}} 

我真的想一些從你PPL幫助。

任何幫助表示讚賞帥哥。

回答

0

那麼,如果你只想在按鈕按下時播放視頻。有兩種方法

1)拆下myVideoView.start();形成的代碼,我認爲這將停止視頻的負載

2)另一個方法則沒有設置默認MediaController玩視頻視圖

您可以創建自定義播放按鈕播放視頻,並給myVideoView.start();裏面的onClick

Button play = (Button) findViewById(R.id.btnPlay); 
play .setOnClickListener(this); 
Button pause = (Button) findViewById(R.id.btnPause); 
pause .setOnClickListener(this); 
Button stop = (Button) findViewById(R.id.btnStop); 
stop .setOnClickListener(this); 
public void onClick(View v) { 
switch(v.getId()){ 
case R.id.btnPlay: 
    myVideoView.start(); 
    /* the instruccions of the button */ 
    break; 
case R.id.btnPause: 
    /* the instruccions of the button */ 
    break; 
case R.id.btnStop: 
     myVideoView.stop(); 
    /* the instruccions of the button */ 
    break; 
    } 
} 

而你玩有關視頻的清晰度的東西rtsp鏈接,獲得低屈ality視頻前夕你可以看到鏈接itselp你可以看到.3gp延伸這是低質量

如果你想提高質量。有關注這個 YouTube api

REFER

+0

供感謝名單了很多好友 – user1794499 2013-03-09 02:40:06

+0

取出。開始()@ user1794499是否能解決您的問題,請接受的答案,解決了視頻自動播放贊成票它 – edwin 2013-03-10 17:00:03