2024年3月28日发(作者:)

传智播客:安卓教程-视频播放器

1.6.1

使用 MediaPlayer+SurfaceView 播放视频

在该节中,视频播放依然使用 MediaPlayer 类,为了方便演示,我们直接使用本文 1.5 章节中创建

的工程,只需在布局文件添加 SurfaceView 控件即可。

布局文件如下所示。

【文件 1-9】 activity_

1.

2.

3.

4.

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

17.

18.

19.

20.

21.

22.

23.

24.

25.

26.

27.

28.

29.

30.

31.

32.

33.

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

>