android做一个音乐播放器,制作一个简单的Android版的音乐播放器

本文详述了如何使用Android Studio构建一个简单的音乐播放器应用,具备播放、暂停、显示时长等功能。通过创建MusicService、MusicInterface以及更新MainActivity来实现音乐播放逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

音乐播放器是一个非常常见的应用,这篇博客就是介绍如何制作一个简单的音乐播放器,这款音乐播放器具有以下的功能:播放歌曲、暂停播放歌曲、、显示歌曲的总时长、显示歌曲的当前播放时长、调节滑块可以将歌曲调节到任何时间播放、退出音乐播放器

实现效果如下

0818b9ca8b590ca3270a3433284dd417.png

实现方式:

第一步:使用Android Studio创建一个Android工程,并且修改activity_main.xml文件

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="com.fyt.musicplayer.MainActivity"

android:orientation="vertical">

android:id="@+id/sb"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/tv_progress"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="00:00"/>

android:id="@+id/tv_total"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:text="00:00"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="播放音乐"

android:onClick="play"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="暂停播放"

android:onClick="pausePlay"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="继续播放"

android:onClick="continuePlay"/>

android:layout_width="wrap_content"

android:layout_h

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值