2012-01-31 5 views
1

私はギャラリービューを作成していると私は(任意のビデオリンクのような)ビデオを表示したいと私は、この画像をギャラリービューで表示するにはどうすればいいですか?

http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html

が、その表示は何ものように働いてきました。私は一日中過ごすが結果はない。私を助けてください。

ありがとうございます。

+0

ギャラリーにビデオファイルの数を表示しようとしていますか? –

+0

@YugandharBabuはいギャラリーにファイルを表示したくありません – Newts

答えて

4

私は自分の答えを持っています。

私は、各ビデオのサムネイルを作成し、この

Bitmap bm = ThumbnailUtils.createVideoThumbnail(path1.getPath()+"/"+filenames1[position], MediaStore.Images.Thumbnails.MINI_KIND); 

や画像などのギャラリー内の各ビデオ・ショーのようなギャラリーにそれらを表示する必要があります。 GridViewコントロールから直接ビデオを再生するために

2

私はあなたが必要とするものを手に入れていませんが、アクティビティで単一のビューを開くには、ACTION_VIEWインテントを使用することをお勧めします。

public void startVideo(String videoAddress){ 
     Intent intent = new Intent(Intent.ACTION_VIEW); 
     intent.setDataAndType(Uri.parse(videoAddress), "video/3gpp"); // The Mime type can actually be determined from the file 
     activity.startActivity(intent); 
    } 

しかし、この意図では、ビデオのプレーヤーを選択するようユーザーに求められます。私のほとんどの場合、私はより有用VideoViewタグを使用して見つかった - ちょうどビデオをフルスクリーンで表示します。

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <VideoView 
     android:id="@+id/video_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" /> 

</FrameLayout> 

あなたはジェスチャー検出器を使用して、新しいビデオのロード機能を実装することができ、多くの動画の間で閲覧できるようにしたい場合:

GestureDetector gestureDetector = new GestureDetector(new MyGestureDetector() { 

    @Override 
    public void swipeRight() { 
     if (currentArticle > 0) { 
      currentArticle--; 
      loadPage(); 
     } 

    } 

    @Override 
    public void swipeLeft() { 
     if (currentArticle == articleList.size()) { 
      return; 
     } else { 
      currentArticle++; 
      loadPage(); 
     } 
    } 

}); 

View.OnTouchListener gestureListener = new View.OnTouchListener() { 
    public boolean onTouch(View v, MotionEvent event) { 
     return gestureDetector.onTouchEvent(event); 
    } 
}; 

願わくは私の提案のいくつかがあなたに役立つことを望みます。

+0

ありがとうございますが、私には役に立たない。ギャラリーのビデオの数を求めています – Newts

+0

あなたのニーズに応える最後のビットではありませんか?私はあなたが正しく取得する場合、一度に1つのビデオを表示する必要がありますか?その後、ジェスチャー検出器を使用して左右にスワイプできます... –

0

次の関数で

ます。public void playVideo(文字列のURLを)動画のURLを渡す必要があり、{

Intent intent = new Intent(); 
    intent.setAction(Intent.ACTION_VIEW); 
    intent.setDataAndType(Uri.parse("file://" + url), "video/*"); 
    startActivity(intent); 
} 
関連する問題