2012-03-20 67 views
-1

有沒有人在Android中使用Eclipse來播放播放列表中的視頻。請讓我知道如何開始。Android中的視頻播放列表

非常感謝您的時間。

+0

https://www.google.co.in/#hl=en&sugexp=llsin&gs_nf=1&cp=16&gs_id=1n&xhr=t&q=how+to +播放+視頻+在+機器人&PF = p&sclient = PSY-AB和OQ =如何+播放+參見&水溶液= 0&AQI = G4&AQL =&gs_sm =&gs_upl =&gs_l =&PBX = 1&BAV = on.2,or.r_gc.r_pw.r_cp.r_qf 。,cf.osb&fp = 8eada5fd6c3ecbd9&biw = 1600&bih = 758 – 2012-03-20 10:14:05

+0

請不要誤會我我是純粹的初學者android.could你請發送給我下面的程序的main.xml代碼 – user1280083 2012-03-20 10:20:59

回答

1

在這所有的視頻進來列表從SD卡

package com.exercise.AndroidListMedia; 

     import android.app.ListActivity; 
     import android.content.Intent; 
     import android.database.Cursor; 
     import android.net.Uri; 
     import android.os.Bundle; 
     import android.provider.MediaStore; 
     import android.util.Log; 
     import android.view.View; 
     import android.widget.ListView; 
     import android.widget.SimpleCursorAdapter; 
     import android.widget.Toast; 

     public class AndroidListMediaActivity extends ListActivity { 

     SimpleCursorAdapter adapter; 

     final Uri mediaSrc = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     String[] from = {MediaStore.MediaColumns.TITLE}; 
     int[] to = { 
      android.R.id.text1}; 

      Cursor cursor = managedQuery(
      mediaSrc, 
      null, 
      null, 
      null, 
      MediaStore.Audio.Media.TITLE); 

     adapter = new SimpleCursorAdapter(this, 
      android.R.layout.simple_list_item_1, cursor, from, to); 
     setListAdapter(adapter); 
    } 

    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) { 
    Cursor cursor = adapter.getCursor(); 
    cursor.moveToPosition(position); 

    String _id =  cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media._ID)); 

    Uri playableUri 
     = Uri.withAppendedPath(mediaSrc, _id); 

    Toast.makeText(this, "Play: " + playableUri.toString(), Toast.LENGTH_LONG).show(); 
    //Log.e("tssssssssss",playableUri.toString()); 


    Intent intent = new Intent(); 
    intent.setClass(AndroidListMediaActivity.this, 
      PlayerActivity.class); 
    intent.setData(playableUri); 
    startActivity(intent); 
} 


    } 
+0

你可以請給我main.xml到上面的程序 – user1280083 2012-03-20 10:23:53

+0

與manifest.xml – user1280083 2012-03-20 10:24:23