2011-12-29 267 views
0

我的確嘗試過在這裏查看,並且要解決這個問題,但沒有運氣,可能是因爲是新手。無法在Android VideoView和MediaPlayer中播放mp4視頻

任務:我要上android app

TRIALS發揮RTSP視頻流:我嘗試了用2min mp4視頻複製到與Media Player和VideoViewres\raw文件夾。後來我用了API Demo樣品和我設置:

path = "android.resourcee://com.me.mobile/R.raw.mithlat"; 

錯誤:MediaPlayer API演示只是一個空白頁面,沒有視頻沒有聲音 上VideoView API演示它顯示

"Sorry this video cannot be played" 

CONFIG : 我的目標是2.33(這是測試與)

minimun is 2.1

謝謝

回答

0

嘗試流的rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov。在瀏覽器中輸入它,它會自動使用android本地播放器打開。如果這樣玩,那麼你可能需要再次看看你的流。我沒有Android 2.3,但我在Android 3.2中播放了相同的URL,並且它工作正常。還請檢查Playing a video in VideoView in Android的答案供您參考。希望這可以幫助你我猜android2.3不支持rtsp雖然不是很確定。嘗試網址,並檢查它是否正在播放

2

視頻流或播放視頻需要太多的權力。有時它不會玩模擬器。嘗試將其運行到您的手機。

嘗試此代碼並將其運行到您的手機。

public void onCreate(Bundle savedInstanceState){ 
setContentView(R.layout.main); 
String videourl = "http://something.com/blah.mp4"; 
Uri uri = Uri.parse(videourl); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
intent.setDataAndType(uri, "video/mp4"); 
startActivity(intent); 
} 

Click here to watch Android Video Streaming Tutorial

+0

感謝...請把你的名字! – 2013-10-18 05:02:01

0

請嘗試以下代碼用於播放視頻的videoView

VideoView videoView = (VideoView)findViewById(R.id.VideoView); 
Uri uri = Uri.parse("android.resource://" + getPackageName()+"/"+ R.raw.demo7); 
video.setVideoURI(uri); 
video.start(); 
+0

請將「R.raw.demo7」更改爲相應的視頻名稱 – Joms 2013-09-25 08:31:33