# AudioPlayerView
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AudioPlayerView-green.svg?style=true)](https://android-arsenal.com/details/1/3140)
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)
[![](https://jitpack.io/v/HugoMatilla/AudioPlayerView.svg)](https://jitpack.io/#HugoMatilla/AudioPlayerView)
AudioPlayerView is an Android view that loads audio from an url and have basic playback tools.
It makes use of the Android [MediaPlayer](http://developer.android.com/intl/es/reference/android/media/MediaPlayer.html) library.
![alt text](./art/AudioPlayerView-Sample.gif)
_Unfortunately this gif doesn't play audio :) check the sample app to hear it._
## Update from 1.0.0 to 1.0.1
Change the package repository to jitpack as explained in next section.
## Include
Include the Gradle dependency from `jitpack`
```java
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
...
compile 'com.github.HugoMatilla:AudioPlayerView:v1.0.1'
}
```
## Permissions
AudioPlayerView adds automatically the `android.permission.INTERNET` permission.
## Use
Add the view to your xml.
```xml
<com.hugomatilla.audioplayerview.AudioPlayerView
android:id="@+id/player"
...
/>
```
Use it in your Activity, Fragment or Custom View
```java
String url = "url-to-your-mp3-file.mp3"
AudioPlayerView audioPlayerView = (AudioPlayerView) findViewById(R.id.player);
audioPlayerView.withUrl(url);
```
## Callbacks
There are 3 callbacks:
`onAudioPreparing`: while the file is being downloaded. Use it if you want to show a progress dialog.
`onAudioReady`: when the file has finished to be downloaded and is about to start playing. You can use it to hide the progress dialog.
`onAudioFinished`: When the audio has finished playing and is stopped.
```java
audioPlayerView.setOnAudioPlayerViewListener(new AudioPlayerView.OnAudioPlayerViewListener() {
@Override
public void onAudioPreparing() {
spinner.setVisibility(View.VISIBLE);
}
@Override
public void onAudioReady() {
spinner.setVisibility(View.INVISIBLE);
}
@Override
public void onAudioFinished() {
}
});
```
## UI
You can use icons or texts to show the current state of the view: loading, playing or stopped.
The AudioPlayerView extends TextView, so you can do all of the things you would do in a TextView with some considerations.
### Icons
For the icons, AudioPlayerView uses icon fonts. When the audio is ready and playing it shows a stop icon, when is finished or it was never started it shows a play button and when is preparing it shows a spinner (spinning).
The spinner icon makes the whole _textView_ spin, so if it has a background color and it is not a round shape you probably won't get what you expected (the icon to spin) but you will see the whole rectagle spinning. In the sample application you can see how to do it.
### Text
If you prefer to use text, add the texts to the xml file, and `app:useIcons="false"`.
```xml
<com.hugomatilla.audioplayerview.AudioPlayerView
...
app:loadingText="loading..."
app:playText="play"
app:stopText="stop"
app:useIcons="false"
/>
```
### Custom Icons
You can use your own icon fonts.
```xml
<com.hugomatilla.audioplayerview.lib.AudioPlayerView
...
app:loadingText="@string/customLoadingIcon"
app:playText="@string/customPlayIcon"
app:stopText="@string/customStopIcon"
app:useIcons="true"
/>
```
You can create your own icon fonts with [fontello.com](http://fontello.com/)
## API
The only public method to manage the audio playback is `toggleAudio()`
It plays the audio if it is stopped or it was never started (previous load), and it stops the audio if it is playing.
## Destroy
Dont forget to destroy the AudioPlayerView when you don't need it anymore. The `onDestroy()` method of the activity is a good place to have it.
```java
@Override
protected void onDestroy() {
audioPlayerView.destroy();
super.onDestroy();
}
```
## License
The MIT License (MIT)
Copyright (c) 2016 Hugo Matilla
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.
没有合适的资源?快使用搜索试试~ 我知道了~
AudioPlayerView是一个Android视图,可从URL加载音频并具有基本的播放工具。-Android开发
共75个文件
xml:18个
css:12个
java:6个
需积分: 10 2 下载量 93 浏览量
2021-05-26
11:53:33
上传
评论
收藏 268KB ZIP 举报
温馨提示
AudioPlayerView AudioPlayerView是一个Android视图,可从URL加载音频并具有基本的播放工具。 它利用了Android MediaPlayer库。 不幸的是,此gif无法播放音频:)检查示例AudioPlayerView AudioPlayerView是一个Android视图,可从URL加载音频并具有基本的播放工具。 它利用了Android MediaPlayer库。 不幸的是,此gif无法播放音频:)检查示例应用程序以收听音频。 从1.0.0更新到1.0.1,如下一节所述,将软件包存储库更改为jitpack。 包括包括jitpack allprojects {存储库{... maven {url“ https://jitpack.io”
资源详情
资源评论
资源推荐
收起资源包目录
AudioPlayerView-master.zip (75个子文件)
AudioPlayerView-master
fonts
avp-font-custom
font
audio-player-view-font-custom.svg 1KB
audio-player-view-font-custom.woff 3KB
audio-player-view-font-custom.eot 5KB
audio-player-view-font-custom.ttf 5KB
demo.html 6KB
LICENSE.txt 206B
css
audio-player-view-font-custom-embedded.css 13KB
audio-player-view-font-custom-codes.css 179B
audio-player-view-font-custom-ie7.css 604B
animation.css 2KB
audio-player-view-font-custom.css 2KB
audio-player-view-font-custom-ie7-codes.css 332B
README.txt 3KB
config.json 27KB
avp-font
font
audio-player-view-font.eot 6KB
audio-player-view-font.svg 2KB
audio-player-view-font.woff 3KB
demo.html 6KB
LICENSE.txt 395B
css
animation.css 2KB
audio-player-view-font-ie7-codes.css 310B
audio-player-view-font-codes.css 157B
audio-player-view-font-ie7.css 575B
audio-player-view-font-embedded.css 13KB
audio-player-view-font.css 2KB
README.txt 3KB
config.json 27KB
.gitignore 97B
app
.gitignore 7B
build.gradle 650B
src
androidTest
java
com
hugomatilla
audioplayerview
sample
ApplicationTest.java 369B
main
AndroidManifest.xml 683B
res
mipmap-xhdpi
ic_launcher.png 5KB
mipmap-mdpi
ic_launcher.png 2KB
layout
activity_main.xml 3KB
values-w820dp
dimens.xml 358B
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-hdpi
ic_launcher.png 3KB
mipmap-xxxhdpi
ic_launcher.png 10KB
values
strings.xml 237B
colors.xml 208B
dimens.xml 211B
styles.xml 383B
assets
audio-player-view-font-custom.ttf 5KB
java
com
hugomatilla
audioplayerview
sample
MainActivity.java 2KB
test
java
com
hugomatilla
audioplayerview
sample
ExampleUnitTest.java 331B
proguard-rules.pro 675B
settings.gradle 35B
art
AudioPlayerView-Sample.gif 699KB
build.gradle 479B
gradlew 5KB
audioplayerview
.gitignore 7B
build.gradle 777B
src
androidTest
java
com
hugomatilla
audioplayerview
ApplicationTest.java 362B
main
AndroidManifest.xml 366B
res
anim
rotate_indefinitely.xml 341B
values
strings.xml 219B
attrs.xml 335B
assets
audio-player-view-font.ttf 5KB
java
com
hugomatilla
audioplayerview
AudioPlayerView.java 7KB
test
java
com
hugomatilla
audioplayerview
ExampleUnitTest.java 324B
proguard-rules.pro 675B
README.md 5KB
gradlew.bat 2KB
gradle.properties 855B
.idea
misc.xml 5KB
encodings.xml 159B
gradle.xml 861B
copyright
profiles_settings.xml 74B
runConfigurations.xml 564B
compiler.xml 656B
.name 15B
modules.xml 512B
gradle
wrapper
gradle-wrapper.properties 231B
gradle-wrapper.jar 52KB
共 75 条
- 1
法学晨曦
- 粉丝: 15
- 资源: 4608
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 筷手引流工具.apk
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0