0

나는 ListView을 가지고 있으며 비디오 양식 URL로 채 웁니다. ListView 어댑터의 그림을 URL에서 쉽게 표시 할 수 있지만 비디오 축소판을로드하는 방법은 무엇입니까?Video Thumbnail을 ListView 어댑터의 Video URL에서로드하는 방법

+0

호출 한 JSON 응답 또는 API를 공유 할 수 있습니까?! –

+0

예 비디오 및 이미지의 정확한 경로를 모두 얻었지만 이미지 및 비디오 thumnail이 표시되지 않음 –

+1

피카소와 같은 많은 이미지로드 라이브러리는 사용자가 비디오에 'Uri'를 제공하면 사용자의 축소판을 얻을 수 있습니다 . – CommonsWare

답변

5

MediaMetadataRetriever을 사용하면 동영상 미리보기 이미지를 얻을 수 있습니다.

new AsyncTask<Void, Void, Bitmap>() { 

    @Override 
    protected Bitmap doInBackground(Void... params) { 
     Bitmap bitmap = null; 
     String videoPath = "http://techslides.com/demos/sample-videos/small.mp4"; 
     MediaMetadataRetriever mediaMetadataRetriever = null; 
     try { 
      mediaMetadataRetriever = new MediaMetadataRetriever(); 
      if (Build.VERSION.SDK_INT >= 14) 
       // no headers included 
       mediaMetadataRetriever.setDataSource(videoPath, new HashMap<String, String>()); 
      else 
       mediaMetadataRetriever.setDataSource(videoPath); 
      // mediaMetadataRetriever.setDataSource(videoPath); 
      bitmap = mediaMetadataRetriever.getFrameAtTime(); 
     } catch (Exception e) { 
      e.printStackTrace(); 

     } finally { 
      if (mediaMetadataRetriever != null) 
       mediaMetadataRetriever.release(); 
     } 
     return bitmap; 
    } 

    @Override 
    protected void onPostExecute(Bitmap bitmap) { 
     super.onPostExecute(bitmap); 
     if (bitmap != null) 
      ((ImageView) findViewById(R.id.your_image_id)).setImageBitmap(bitmap); 
    } 
}.execute(); 
+0

더 많은 thumnails를로드하려면이 내부 목록보기 어댑터를 사용할 수 있습니까? –

+0

@ listviewadapter에서 하나의 비디오 thumnails를로드 할 수 있지만 같은 listviewadapter의 다른 비디오에 대해 더 많은 thumnails를로드 할 수 없습니다. –

+0

비트 맵을받은 후 콜백을 구현하고 어댑터의 이미지 뷰를 업데이트해야합니다. –