MediaPlayer 可 以 播 放 音 频 和 视 频 , 另 外 也 可 以 通 过 VideoView 来 播 放 视 频 , 虽 然
VideoView 比 MediaPlayer 简单易用 ,但 定制性 不如用 MediaPlayer ,要 视情况 选择 了 。
MediaPlayer 播放音频比较简单,但是要播放视频就需要 SurfaceView。 SurfaceView 比普通
的自定义 View 更有绘图上的优势,它支持完全的 OpenGL ES 库。
[
代码
] main.xml
0
1
<?xml version="1.0" encoding="utf-8"?>
0
2
<LinearLayout
android:id="@+id/LinearLayout01"
0
3
%%%%android:layout_width=")ll_parent"
android:layout_height=")ll_parent"
0
4
%%%%xmlns:android="http://schemas.android.com/apk/res/android"
0
5
%%%%android:orientation="vertical">
0
6
%%%%<SeekBar android:id="@+id/SeekBar01"
android:layout_height="wrap_content"
0
7
%%%%%%%%android:layout_width=")ll_parent"></SeekBar>
0
8
%%%%<LinearLayout android:id="@+id/LinearLayout02"
0
9
%%%%%%%%android:layout_width="wrap_content"
android:layout_height="wrap_content">
1
0
%%%%%%%%<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
1
1
%%%%%%%%%%%%android:layout_height="wrap_content" android:text="播放
音频"></Button>
1
2
%%%%%%%%<Button android:id="@+id/Button02"
android:layout_width="wrap_content"
1
3
%%%%%%%%%%%%android:layout_height="wrap_content" android:text="停止
播放"></Button>
1
4
%%%%</LinearLayout>
1
5
%%%%<SeekBar android:id="@+id/SeekBar02"
android:layout_height="wrap_content"
1
6
%%%%%%%%android:layout_width=")ll_parent"></SeekBar>
1 %
评论0
最新资源