我有这在我的第一个活动:
I have this in my first activity:
private AdapterView.OnItemClickListener _itemClickLis = new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Now we want to actually get the data location of the file String [] proj={MEDIA_DATA}; // We request our cursor again _cursor = managedQuery(_contentUri, proj, // Which columns to return null, // WHERE clause; which rows to return (all rows) null, // WHERE clause selection arguments (none) null); // Order-by clause (ascending by name) // We want to get the column index for the data uri int count = _cursor.getCount(); // _cursor.moveToFirst(); // _columnIndex = _cursor.getColumnIndex(MEDIA_DATA); // Lets move to the selected item in the cursor _cursor.moveToPosition(position); // And here we get the filename String filename = _cursor.getString(_columnIndex); //*********** You can do anything when you know the file path :-) showToast(filename); Intent i = new Intent("com.ave.EDITORSCREEN"); i.putExtra("mnt/sdcard-ext", _ID); startActivity(i); }这是不是完整code,但作为全code从SD卡收集所有的视频缩略图,并显示他们沿着他们的道路的(在祝酒词)。我希望能够点击缩略图,并传递到下一个活动的数据进行播放,停止,暂停,等你能看到我在第一个活动传递的数据:
This is not the full code, but as the full code gathers all the video thumbnails from the sd card and displays them along with their path's (in toasts). I want to be able to click a thumbnail and have the data passed on to the next activity to be played, stopped, paused, etc. You can see where I have passed the data in the first activity:
public class Editor extends Activity { ImageButton video1; int isClicked = 0; ImageButton audio; int isClicked1 = 0; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.editor); video1 = (ImageButton) findViewById(R.id.video1); video1.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (isClicked == 0) { video1.setImageResource(R.drawable.video_pressed); isClicked = 1; } else { video1.setImageResource(R.drawable.video1); isClicked = 0; } } }); audio = (ImageButton) findViewById(R.id.audio); audio.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (isClicked1 == 0) { audio.setImageResource(R.drawable.audio_pressed); isClicked1 = 1; } else { audio.setImageResource(R.drawable.audio); isClicked1 = 0; } } }); } }我想象得到的数据,我将需要把
I imagine to get the data I will need to put
String data = getIntent().getStringExtra("mnt/sdcard-ext");但是,在onCreate方法?或者是这甚至得到传递数据的正确方法?最后一点我怎么能我可以播放视频?是否有某种code为说一个视频播放器?如果是的话我会在哪里放置这在我的最后一个活动?
But where the onCreate method? Or is this even the right way to get the passed data? And lastly how can I can I play the video? Is there some sort of code for say a video player? If so where would I place this in my final activity?
推荐答案您不必做在的onCreate()方法,但为什么不呢?你还有什么地方把它?
You do not have to do it in the onCreate() method, but why not? Where else would you put it?
如果你正在寻找任何类型的文档,我会建议您检查出 Android开发者的Java(Android版)文件。该 Android开发者有一个伟大的网站在一般情况下,所有关于机器人。我认为,一个良好的开端与Android 音频/视频是这里。
If you are looking for any sort of documentation, I would recommend checking out the Android Developers Java(Android)Doc. The Android Developers have a great site in general, all about Android. I think a good place to start with Android Audio/Video is here.
一般情况下,你会设置你的MediaPlayer界面的布局(播放/暂停按钮和视图)的的onCreate(),并设置你的点击/触摸听众是当接收输入时执行。
Generally, you would set up the layout of your MediaPlayer interface (Play/Pause buttons and views) in onCreate() and also setup your click/touch listeners to be executed when input is received.
有关第一个编程课程,它看起来像你正在做pretty好。祝你好运!
For a first programming course, it looks like you are doing pretty well. Good Luck!
更多推荐
在Android的正确传递数据?
发布评论