{"id":3667,"url":"https://github.com/HugoMatilla/AudioPlayerView","last_synced_at":"2025-07-31T13:30:44.346Z","repository":{"id":86125523,"uuid":"51527272","full_name":"HugoMatilla/AudioPlayerView","owner":"HugoMatilla","description":"AudioPlayerView is an Android view that loads audio from an url and have basic playback tools.","archived":false,"fork":false,"pushed_at":"2018-03-14T11:44:27.000Z","size":310,"stargazers_count":85,"open_issues_count":3,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-14T18:41:44.575Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HugoMatilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-02-11T16:15:02.000Z","updated_at":"2024-10-18T14:35:02.000Z","dependencies_parsed_at":"2023-07-28T00:46:18.105Z","dependency_job_id":null,"html_url":"https://github.com/HugoMatilla/AudioPlayerView","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoMatilla%2FAudioPlayerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoMatilla%2FAudioPlayerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoMatilla%2FAudioPlayerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoMatilla%2FAudioPlayerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HugoMatilla","download_url":"https://codeload.github.com/HugoMatilla/AudioPlayerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228248551,"owners_count":17891447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:48.007Z","updated_at":"2024-12-05T06:31:37.383Z","avatar_url":"https://github.com/HugoMatilla.png","language":"HTML","funding_links":[],"categories":["Media","Libraries"],"sub_categories":["Other"],"readme":"# AudioPlayerView\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AudioPlayerView-green.svg?style=true)](https://android-arsenal.com/details/1/3140)\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n[![](https://jitpack.io/v/HugoMatilla/AudioPlayerView.svg)](https://jitpack.io/#HugoMatilla/AudioPlayerView)\n\n\nAudioPlayerView is an Android view that loads audio from an url and have basic playback tools.\n\nIt makes use of the Android [MediaPlayer](http://developer.android.com/intl/es/reference/android/media/MediaPlayer.html) library.\n\n![alt text](./art/AudioPlayerView-Sample.gif)  \n\n_Unfortunately this gif doesn't play audio :) check the sample app to hear it._\n\n## Update from 1.0.0 to 1.0.1\nChange the package repository to jitpack as explained in next section.\n## Include\n\nInclude the Gradle dependency from `jitpack`\n\n```java\n\n    allprojects {\n        repositories {\n            ...\n            maven { url \"https://jitpack.io\" }\n        }\n    }\n\n    dependencies {\n        ...\n        compile 'com.github.HugoMatilla:AudioPlayerView:v1.0.1'\n    }\n```\n\n## Permissions\n\nAudioPlayerView adds automatically the `android.permission.INTERNET`  permission.\n\n## Use\n\nAdd the view to your xml.\n\n```xml\n\n    \u003ccom.hugomatilla.audioplayerview.AudioPlayerView\n                android:id=\"@+id/player\"\n                ...\n    /\u003e\n```\n\nUse it in your Activity, Fragment or Custom View\n```java\n    \n    String url = \"url-to-your-mp3-file.mp3\"\n    AudioPlayerView audioPlayerView = (AudioPlayerView) findViewById(R.id.player);\n    audioPlayerView.withUrl(url);\n```\n\n## Callbacks\nThere are 3 callbacks:\n\n`onAudioPreparing`: while the file is being downloaded. Use it if you want to show a progress dialog.\n\n`onAudioReady`: when the file has finished to be downloaded and is about to start playing. You can use it to hide the progress dialog.\n\n`onAudioFinished`: When the audio has finished playing and is stopped.\n\n```java\n    \n    audioPlayerView.setOnAudioPlayerViewListener(new AudioPlayerView.OnAudioPlayerViewListener() {\n            @Override\n            public void onAudioPreparing() {\n                spinner.setVisibility(View.VISIBLE);\n            }\n\n            @Override\n            public void onAudioReady() {\n                spinner.setVisibility(View.INVISIBLE);\n            }\n\n            @Override\n            public void onAudioFinished() {\n\n            }\n        });\n```\n\n## UI\nYou can use icons or texts to show the current state of the view: loading, playing or stopped.\n\nThe AudioPlayerView extends TextView, so you can do all of the things you would do in a TextView with some considerations.\n\n### Icons\nFor 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).\n\nThe 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.\n\n### Text\nIf you prefer to use text, add the texts to the xml file, and `app:useIcons=\"false\"`.\n\n```xml\n\n    \u003ccom.hugomatilla.audioplayerview.AudioPlayerView\n        ...\n        app:loadingText=\"loading...\"\n        app:playText=\"play\"\n        app:stopText=\"stop\"\n        app:useIcons=\"false\"\n    /\u003e\n``` \n\n### Custom Icons\n\nYou can use your own icon fonts.\n\n```xml\n\n    \u003ccom.hugomatilla.audioplayerview.lib.AudioPlayerView\n        ...\n        app:loadingText=\"@string/customLoadingIcon\"\n        app:playText=\"@string/customPlayIcon\"\n        app:stopText=\"@string/customStopIcon\"\n        app:useIcons=\"true\"\n    /\u003e\n``` \n\nYou can create your own icon fonts with [fontello.com](http://fontello.com/)\n\n## API \n\nThe only public method to manage the audio playback is `toggleAudio()` \n\nIt plays the audio if it is stopped or it was never started (previous load), and it stops the audio if it is playing. \n\n## Destroy\n\nDont 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.\n\n```java\n\n    @Override\n    protected void onDestroy() {\n        audioPlayerView.destroy();\n        super.onDestroy();\n    }\n```\n\n## License\nThe MIT License (MIT)\n\nCopyright (c) 2016 Hugo Matilla\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHugoMatilla%2FAudioPlayerView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHugoMatilla%2FAudioPlayerView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHugoMatilla%2FAudioPlayerView/lists"}