# MusicBobber **Repository Path**: chinasoft5_ohos/MusicBobber ## Basic Information - **Project Name**: MusicBobber - **Description**: 音频小部件 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-14 - **Last Updated**: 2021-09-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MusicBobber #### 项目介绍 - 项目名称:MusicBobber - 所属系列:openharmony的第三方组件适配移植 - 功能:音频小部件 - 项目移植状态:主功能完成,暂无发加载加载音频资源的图片,循环播放偶尔无法自动播放下一首 - 调用差异:无 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:1.0.2 #### 效果演示 ![MusicBobber](/screenshots/musicBobber.gif) #### 安装教程 1.在项目根目录下的build.gradle文件中, ``` allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中, ``` dependencies { implementation 'com.gitee.chinasoft_ohos:MusicBobber:1.0.0' ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 初始化 ``` AudioWidget audioWidget = new AudioWidget.Builder(context) .lightColor(...) .darkColor(...) .expandWidgetColor(...) .progressColor(...) .progressStrokeWidth(...) .crossColor(...) .crossOverlappedColor(...) .crossStrokeWidth(...) .buttonPadding(...) .bubblesMinSize(...) .bubblesMaxSize(...) .shadowColor(...) .shadowRadius(...) .shadowDx(...) .shadowDy(...) .playDrawable(...) .pauseDrawable(...) .playlistDrawable(...) .prevTrackDrawale(...) .nextTrackDrawable(...) .defaultAlbumDrawable(...) .edgeOffsetXCollapsed(...) .edgeOffsetYCollapsed(...) .edgeOffsetXExpanded(...) .edgeOffsetYExpanded(...) .build(); ``` 或者您可以使用默认配置.如下: ``` AudioWidget audioWidget = new AudioWidget.Builder(context).build(); ``` 然后你可以使用音频小部件的控制器来监听事件: ``` // media buttons' click listener audioWidget.controller().onControlsClickListener(new AudioWidget.OnControlsClickListener() { @Override public boolean onPlaylistClicked() { // playlist icon clicked // return false to collapse widget, true to stay in expanded state } @Override public void onPreviousClicked() { // previous track button clicked } @Override public boolean onPlayPauseClicked() { // return true to change playback state of widget and play button click animation (in collapsed state) return true; } @Override public void onNextClicked() { // next track button clicked } @Override public void onAlbumClicked() { // album cover clicked } @Override public void onPlaylistLongClicked() { // playlist button long clicked } @Override public void onPreviousLongClicked() { // previous track button long clicked } @Override public void onPlayPauseLongClicked() { // play/pause button long clicked } @Override public void onNextLongClicked() { // next track button long clicked } @Override public void onAlbumClicked() { // album cover long clicked } @Override public void onAlbumLongClicked() { // album cover long clicked } }); // widget's state listener audioWidget.controller().onWidgetStateChangedListener(new AudioWidget.OnWidgetStateChangedListener() { @Override public void onWidgetStateChanged(@NonNull AudioWidget.State state) { // widget state changed (COLLAPSED, EXPANDED, REMOVED) } @Override public void onWidgetPositionChanged(int cx, int cy) { // widget position change. Save coordinates here to reuse them next time AudioWidget.show(int, int) called. } }); ``` 使用 AudioWidget.Controller,您可以设置曲目的持续时间、当前位置或专辑封面。您还可以使用 start()、pause() 或 stop() 方法设置当前播放状态。有关如何使用控制器的更多信息,请参阅MusicService类。 要在屏幕上显示音频小部件,请调用AudioWidget.show(int, int)方法。要隐藏它,请调用AudioWidget.hide()方法。很简单的! ``` audioWidget.show(100, 100); // coordinates in pixels on screen from top left corner ... audioWidget.hide(); ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.0 #### 版权和许可信息 Copyright (c) 2016 Cleveroad Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.