我試圖在我的應用程序中顯示圖像和視頻。爲此,我正在使用RecyclerView
。圖像正在顯示,但視頻不顯示。該視頻完全下載,但它不在OnPreparedListener
VideoView
內。如果我只使用VideoView
視頻正在播放....請提出一些解決方案....謝謝。 (如果有人想看到的代碼,我將發佈)內部滾動視圖(ScrollView/RecyclerView/ListView)視頻不在播放。
我以前TextureView
和SurfaceView
還,我得到同樣的問題,這些觀點太...
這是scrollView
和VideoView
樣本示例。
str = "http://files.parsetfss.com/13e1c98b-895f-401e-83f3-7bf9b944001d/tfss-e199dd99-2564-4092-9df8-4b279ca2e7d0-video.mp4";
Ion.with(context)
.load(str)
.progress(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
System.out.println("" + downloaded + "/" + total);
Log.d("TAG", downloaded + "/" + total);
}
})
.write(fileCache.getFile(str))
.setCallback(new FutureCallback<File>() {
@Override
public void onCompleted(Exception e, File file) {
// download done...
Log.d("TAG", file.getAbsolutePath());
// do stuff with the File or error
videoUri = Uri.fromFile(file);
videoView2.setVideoURI(videoUri);
videoView2.requestFocus();
videoView2.setOnPreparedListener
(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(final MediaPlayer mp) {
Log.d("TAG", " mp4 Done ready to play ");
videoView2.start();
mp.setLooping(true);
mp.setVolume(0, 0);
videoView2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d("TAG", " Volume ");
if (abc) {
mp.setVolume(0, 0);
Log.d("TAG", " Volume 0 ");
abc = false;
} else {
mp.setVolume(1, 1);
Log.d("TAG", " Volume 1 ");
abc = true;
}
return false;
}
});
}
}
);
}
});
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="blpacademy.videotestwithscrollandwithout.VideoView_with_scroll">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<VideoView
android:id="@+id/videoView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
更新:
我試着用ListView
與VideoView
太....它也沒有工作....
我所滾動的觀點(ListView
/RecyclerView
內思考/ ScrollView
)視頻(VideoView
)不在播放....如果播放(TextureView
/SurfaceView
)視圖不滾動...
發佈相關代碼! –
你可能想看看:http://stackoverflow.com/a/10161316/295004和Grafika的DoubleDecode活動https://github.com/google/grafika/ –
嗨,@MorrisonChang我檢查了答案,那工作,但在我的情況下,在任何滾動查看視頻不播放....任何想法1 –