2015-01-08 5 views
1

URL의 비디오를 표시하는 목록보기를 만들려고하지만 아무것도 표시하지 않습니다 화면.(URL에서 가져온) 비디오가 배열 어댑터를 사용하여 목록보기에 배치하려고 시도 할 때 표시되지 않습니다.

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.nikhilbuduma.giflistview" > 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".VideoPlayerActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

    <uses-permission android:name="android.permission.INTERNET" /> 

</manifest> 

여기 activity_video_player.xml입니다 :

여기 여기 내 매니페스트의 VideoPlayerActivity.java

package com.example.nikhilbuduma.giflistview; 

import android.app.Activity; 
import android.content.Context; 
import android.graphics.Color; 
import android.media.MediaPlayer; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 
import android.widget.MediaController; 
import android.widget.Toast; 
import android.widget.VideoView; 
import java.util.ArrayList; 

public class VideoPlayerActivity extends Activity { 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_video_player); 
     final ListView listview = (ListView) findViewById(R.id.listview); 

     String[] urls = new String[] {"http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test1_Talkinghead_mp4_480x360.mp4"}; 

     final StableArrayAdapter adapter = new StableArrayAdapter(this, urls); 
     listview.setAdapter(adapter); 
    } 

    private class StableArrayAdapter extends ArrayAdapter<String> { 

     private final Context context; 
     private final String[] values; 

     public StableArrayAdapter(Context context, String[] values){ 
      super(context, R.layout.movie_cell, values); 
      this.context = context; 
      this.values = values; 
     } 

     @Override 
     public View getView(int position, View convertView, ViewGroup parent){ 
      LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      View rowView = inflater.inflate(R.layout.movie_cell, parent, false); 
      final VideoView videoView =(VideoView)rowView.findViewById(R.id.videoView); 
      videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
       public void onCompletion(MediaPlayer mp) { 
        videoView.start(); //need to make transition seamless. 
       } 
      }); 
      videoView.setVideoURI(Uri.parse(values[position])); 
      videoView.requestFocus(); 
      videoView.start(); 
      return rowView; 
     } 

    } 
} 

<?xml version="1.0" encoding="utf-8"?> 
<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

여기 movie_cell.xml :

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

    <VideoView android:id="@+id/videoView" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent"/> 

</RelativeLayout> 
응용 프로그램을 실행할 때 내가 얻을

로그 메시지는 다음과 같습니다

01-07 20:45:50.741 2367-2367/com.example.nikhilbuduma.giflistview I/art﹕ Not late-enabling -Xcheck:jni (already on) 
01-07 20:45:50.855 2367-2382/com.example.nikhilbuduma.giflistview D/OpenGLRenderer﹕ Render dirty regions requested: true 
01-07 20:45:50.857 2367-2367/com.example.nikhilbuduma.giflistview D/﹕ HostConnection::get() New Host Connection established 0xae0f3d30, tid 2367 
01-07 20:45:50.865 2367-2367/com.example.nikhilbuduma.giflistview D/Atlas﹕ Validating map... 
01-07 20:45:50.929 2367-2382/com.example.nikhilbuduma.giflistview D/﹕ HostConnection::get() New Host Connection established 0xa6c4a040, tid 2382 
01-07 20:45:50.946 2367-2382/com.example.nikhilbuduma.giflistview I/OpenGLRenderer﹕ Initialized EGL, version 1.4 
01-07 20:45:50.972 2367-2382/com.example.nikhilbuduma.giflistview D/OpenGLRenderer﹕ Enabling debug mode 0 
01-07 20:45:51.028 2367-2382/com.example.nikhilbuduma.giflistview W/EGL_emulation﹕ eglSurfaceAttrib not implemented 
01-07 20:45:51.028 2367-2382/com.example.nikhilbuduma.giflistview W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xae0e88e0, error=EGL_SUCCESS 
01-07 20:45:51.623 2367-2382/com.example.nikhilbuduma.giflistview W/EGL_emulation﹕ eglSurfaceAttrib not implemented 
01-07 20:45:51.623 2367-2382/com.example.nikhilbuduma.giflistview W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xae0e88e0, error=EGL_SUCCESS 

답변

0

대신 VideoView의, ImageView를 사용하여 영상의 미리보기를 얻을.

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    ... 
    Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(values[position], 
      MediaStore.Video.Thumbnails.MICRO_KIND); 
    imageView.setImageBitmap(thumbnail); 
    ... 
} 
+0

이것은 트릭을 수행하지 않는 것 같습니다. 미리보기 이미지는 표시되지 않습니다. 내가 작성한 코드에 더 깊은 문제가 있다고 생각합니까? – darksigma