(1)任务描述
中控大屏仪表屏幕中间显示媒体组件,组件内上方显示正在播放的媒体信息例如“歌曲名称”“音视频名称”信息栏、“音量显示”。
信息栏下方显示播放控制按钮,“播放/暂停”“上一曲下一曲”“音量滑块”“静音”,在操控设备中点击“播放/暂停”,仪表屏中的按钮随之切换“播放/暂停”状态,点击操控设备中的“上一曲下一曲”按钮,仪表屏可切换正在播放媒体信息,点击操控设备中的“静音”按钮,仪表屏幕“音量显示”调节到静音模式。
中控大屏主屏中显示当前播放的歌曲名称、歌曲进度和歌词,显示“播放/暂停”“上一曲下一曲”“音量滑块”“静音”按钮,点击各自按钮可对当前播放的歌曲进行操作。
主页面用卡片列表展示该设备中所有的视频信息,卡片上半部分展示该视频的预览图,下半部分显示视频名称和“上次看到 xx 分xx 秒”信息。
点击对应的视频卡片,对应的屏幕会进入视频播放页面,并播放所选择卡片对应的视频。当点击正在播放的视频时,左上角显示【返回】按钮,点击【返回】则主屏回到影视娱乐 App 主页面。视频播放页面下方显示视频播放器工具栏,工具栏上半部分显示【快进】【快退】【暂停/继续播放】【其他视频】按钮,点击【其他视频】按钮可弹出视频列表弹层,以列表的形式展示其他视频,点击列表项可切换至对应的视频进行播放,页面播放工具栏下半部分显示视频的【当前播放时长】【总时长】和【视频进度条】,可拖动视频进度条调整当前视频播放进度。
步骤一:
首先创建一个android 项目名字自己想
步骤二:在build.gradle中给上ViewBinding等待Sync Now 构建就完成了
步骤三: AndroidManifest.xml中给上权限和文件保存的位置
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
步骤四:构建页面布局(activity_main.xml主界面布局,以及MusicFragment和VideoFragment音乐和视频界面布局 )
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main"
android:background="@drawable/activity_bg"
android:orientation="horizontal">
<LinearLayout
android:layout_width="70dp"
android:layout_height="150dp"
android:layout_gravity="center_vertical"
android:layout_margin="8dp"
android:background="@drawable/text_bg"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/music"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="音乐"
android:textColor="@color/blue"
android:textSize="30px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/video"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="视频"
android:textColor="@color/black"
android:textSize="30px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<FrameLayout
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="50dp" />
</LinearLayout>
fragment_music.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<SeekBar
android:id="@+id/seekBar"
android:layout_width="600px"
android:lay