`
ctfzh
  • 浏览: 30483 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

鉴客 Android 的 MediaPlayer 多媒体播放器

阅读更多

MediaPlayer 可以播放音频和视频,另外也可以通过VideoView来播放视频,虽然VideoView比MediaPlayer简单易用,但定制性不如用 MediaPlayer,要视情况选择了。MediaPlayer播放音频比较简单,但是要播放视频就需要SurfaceView。 SurfaceView比普通的自定义View更有绘图上的优势,它支持完全的OpenGL ES库。

 

程序截图


main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
	android:layout_width="fill_parent" android:layout_height="fill_parent"
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical">
	<SeekBar android:id="@+id/SeekBar01" android:layout_height="wrap_content"
		android:layout_width="fill_parent"></SeekBar>
	<LinearLayout android:id="@+id/LinearLayout02"
		android:layout_width="wrap_content" android:layout_height="wrap_content">
		<Button android:id="@+id/Button01" android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="播放音频"></Button>
		<Button android:id="@+id/Button02" android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="停止播放"></Button>
	</LinearLayout>
	<SeekBar android:id="@+id/SeekBar02" android:layout_height="wrap_content"
		android:layout_width="fill_parent"></SeekBar>

	<SurfaceView android:id="@+id/SurfaceView01"
		android:layout_width="fill_parent" android:layout_height="250px"></SurfaceView>
	<LinearLayout android:id="@+id/LinearLayout02"
		android:layout_width="wrap_content" android:layout_height="wrap_content">
		<Button android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:id="@+id/Button03"
			android:text="播放视频"></Button>
		<Button android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="停止播放" android:id="@+id/Button04"></Button>
	</LinearLayout>
</LinearLayout>
 


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics