{"id":13760596,"url":"https://github.com/florent37/Flutter-AssetsAudioPlayer","last_synced_at":"2025-05-10T11:30:35.285Z","repository":{"id":40244656,"uuid":"167350448","full_name":"florent37/Flutter-AssetsAudioPlayer","owner":"florent37","description":"Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications","archived":false,"fork":false,"pushed_at":"2024-02-28T09:57:30.000Z","size":98571,"stargazers_count":739,"open_issues_count":253,"forks_count":335,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-06-21T18:01:06.635Z","etag":null,"topics":["android","audio","audios","dart","flutter","ios","java","kotlin","listen","mac","macos","media","mp3","player","playlist","song","songs","swift","web"],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/assets_audio_player","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florent37.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"FlorentChampigny","github":"florent37"}},"created_at":"2019-01-24T10:38:56.000Z","updated_at":"2024-06-17T10:37:35.000Z","dependencies_parsed_at":"2024-02-28T10:56:51.743Z","dependency_job_id":null,"html_url":"https://github.com/florent37/Flutter-AssetsAudioPlayer","commit_stats":{"total_commits":790,"total_committers":54,"mean_commits":14.62962962962963,"dds":0.3607594936708861,"last_synced_commit":"0fcc9c55a35c240ca209c24e601d75863281c6d8"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FFlutter-AssetsAudioPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FFlutter-AssetsAudioPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FFlutter-AssetsAudioPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FFlutter-AssetsAudioPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florent37","download_url":"https://codeload.github.com/florent37/Flutter-AssetsAudioPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213808026,"owners_count":15641615,"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":["android","audio","audios","dart","flutter","ios","java","kotlin","listen","mac","macos","media","mp3","player","playlist","song","songs","swift","web"],"created_at":"2024-08-03T13:01:13.733Z","updated_at":"2024-08-03T13:05:07.156Z","avatar_url":"https://github.com/florent37.png","language":"Dart","readme":"# 🎧 assets_audio_player 🔊\n\n[![pub package](https://img.shields.io/pub/v/assets_audio_player.svg)](https://pub.dartlang.org/packages/assets_audio_player)\n\u003ca href=\"https://github.com/Solido/awesome-flutter\"\u003e\n\u003cimg alt=\"Awesome Flutter\" src=\"https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true\u0026style=flat\" /\u003e\n\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/platform-android%20%7C%20ios%20%7C%20macos%20%7C%20web%20-%23989898\" /\u003e\n\n[![Codemagic build status](https://api.codemagic.io/apps/5ed8002fe1907b001c67db52/5ed8002fe1907b001c67db51/status_badge.svg)](https://codemagic.io/apps/5ed8002fe1907b001c67db52/5ed8002fe1907b001c67db51/latest_build)\n[![CodeFactor](https://www.codefactor.io/repository/github/florent37/flutter-assetsaudioplayer/badge)](https://www.codefactor.io/repository/github/florent37/flutter-assetsaudioplayer)\n\nPlay music/audio stored in assets files (simultaneously) directly from Flutter (android / ios / web / macos).\n\nYou can also use play audio files from **network** using their url, **radios/livestream** and **local files**\n\n**Notification can be displayed on Android \u0026 iOS, and bluetooth actions are handled**\n\n```yaml\nflutter:\n  assets:\n    - assets/audios/\n```\n\n```Dart\nAssetsAudioPlayer.newPlayer().open(\n    Audio(\"assets/audios/song1.mp3\"),\n    autoStart: true,\n    showNotification: true,\n);\n```\n\n[![sample1](./medias/sample1.png)](https://github.com/florent37/Flutter-AssetsAudioPlayer)\n[![sample1](./medias/sample2.png)](https://github.com/florent37/Flutter-AssetsAudioPlayer)\n\n# 📥 Import\n\n```yaml\ndependencies:\n  assets_audio_player: ^3.0.8\n```\n\n**Works with `flutter: \"\u003e=3.3.0\"`, be sure to upgrade your sdk**\n\nYou like the package ? buy me a kofi :)\n\n\u003ca href='https://ko-fi.com/A160LCC' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eAudio Source\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🗄️ Asset file (asset path)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🌐 Network file (url)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e📁 Local file (path)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e📻 Network LiveStream / radio (url) \u003cbr/\u003e (\u003cb\u003eDefault, HLS, Dash, SmoothStream\u003c/b\u003e)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eFeature\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🎶 Multiple players\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e💽 Open Playlist\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e💬System notification\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🎧 Bluetooth actions\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🔕 Respect System silent mode\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e📞 Pause on phone call\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eCommands\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e▶ Play\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏸ Pause\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏹ Stop\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏩ Seek(position)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏪⏩ SeekBy(position)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏩ Forward(speed)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏪ Rewind(speed)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏭ Next\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n           \u003ctd\u003e⏮ Prev\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eWidgets\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n           \u003ctd\u003e🐦 Audio Widget\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e🐦 Widget Builders\u003c/td\u003e\n            \u003ctd\u003e✅\u003c/td\u003e\n            \u003ctd\u003e✅\u003c/td\u003e\n            \u003ctd\u003e✅\u003c/td\u003e\n            \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003ctd\u003e🐦 AudioPlayer Builders Extension\u003c/td\u003e\n             \u003ctd\u003e✅\u003c/td\u003e\n             \u003ctd\u003e✅\u003c/td\u003e\n             \u003ctd\u003e✅\u003c/td\u003e\n             \u003ctd\u003e✅\u003c/td\u003e\n         \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eProperties\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🔁 Loop\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🔀 Shuffle\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🔊 get/set Volume\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e⏩ get/set Play Speed\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n\t\u003ctr\u003e\n          \u003ctd\u003e⏩ get/set Pitch\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eListeners\u003c/th\u003e\n            \u003cth\u003eAndroid\u003c/th\u003e\n            \u003cth\u003eiOS\u003c/th\u003e\n            \u003cth\u003eWeb\u003c/th\u003e\n            \u003cth\u003eMacOS\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🦻 Listener onReady(completeDuration)\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n           \u003ctd\u003e🦻 Listener currentPosition\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🦻 Listener finished\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n           \u003ctd\u003e🦻 Listener buffering\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n           \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🦻 Listener volume\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003e🦻Listener Play Speed\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n        \u003c/tr\u003e\n\t\u003ctr\u003e\n          \u003ctd\u003e🦻Listener Pitch\u003c/td\u003e\n          \u003ctd\u003e✅\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n          \u003ctd\u003e🚫\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n# 📁 Import assets files\n\nNo needed to copy songs to a media cache, with assets_audio_player you can open them directly from the assets.\n\n1. Create an audio directory in your assets (not necessary named \"audios\")\n2. Declare it inside your pubspec.yaml\n\n```yaml\nflutter:\n  assets:\n    - assets/audios/\n```\n\n## 🛠️ Getting Started\n\n```Dart\nfinal assetsAudioPlayer = AssetsAudioPlayer();\n\nassetsAudioPlayer.open(\n    Audio(\"assets/audios/song1.mp3\"),\n);\n```\n\nYou can also play _network songs_ from _url_\n\n```Dart\nfinal assetsAudioPlayer = AssetsAudioPlayer();\n\ntry {\n    await assetsAudioPlayer.open(\n        Audio.network(\"http://www.mysite.com/myMp3file.mp3\"),\n    );\n} catch (t) {\n    //mp3 unreachable\n}\n```\n\n_LiveStream / Radio_ from _url_\n\n**The main difference with network, if you pause/play, on livestream it will resume to present duration**\n\n```Dart\nfinal assetsAudioPlayer = AssetsAudioPlayer();\n\ntry {\n    await assetsAudioPlayer.open(\n        Audio.liveStream(MY_LIVESTREAM_URL),\n    );\n} catch (t) {\n    //stream unreachable\n}\n```\n\nAnd play _songs from file_\n\n```Dart\n//create a new player\nfinal assetsAudioPlayer = AssetsAudioPlayer();\n\nassetsAudioPlayer.open(\n    Audio.file(FILE_URI),\n);\n```\n\nfor file uri, please look at https://pub.dev/packages/path_provider\n\n```Dart\nassetsAudioPlayer.playOrPause();\nassetsAudioPlayer.play();\nassetsAudioPlayer.pause();\n```\n\n```Dart\nassetsAudioPlayer.seek(Duration to);\nassetsAudioPlayer.seekBy(Duration by);\n```\n\n```Dart\nassetsAudioPlayer.forwardRewind(double speed);\n//if positive, forward, if negative, rewind\n```\n\n```Dart\nassetsAudioPlayer.stop();\n```\n\n# Notifications\n\n[![notification](./medias/notification_android.png)](https://github.com/florent37/Flutter-AssetsAudioPlayer)\n\n[![notification](./medias/notification_iOS.png)](https://github.com/florent37/Flutter-AssetsAudioPlayer)\n\non iOS, it will use `MPNowPlayingInfoCenter`\n\n1. Add metas inside your audio\n\n```dart\nfinal audio = Audio.network(\"/assets/audio/country.mp3\",\n    metas: Metas(\n            title:  \"Country\",\n            artist: \"Florent Champigny\",\n            album: \"CountryAlbum\",\n            image: MetasImage.asset(\"assets/images/country.jpg\"), //can be MetasImage.network\n          ),\n   );\n```\n\n2. open with `showNotification: true`\n\n```dart\n_player.open(audio, showNotification: true)\n```\n\n## Custom notification\n\nCustom icon (android only)\n\n### By ResourceName\n\nMake sure you added those icons inside your `android/res/drawable` **!!! not on flutter assets !!!!**\n\n```dart\nawait _assetsAudioPlayer.open(\n        myAudio,\n        showNotification: true,\n        notificationSettings: NotificationSettings(\n            customStopIcon: AndroidResDrawable(name: \"ic_stop_custom\"),\n            customPauseIcon: AndroidResDrawable(name:\"ic_pause_custom\"),\n            customPlayIcon: AndroidResDrawable(name:\"ic_play_custom\"),\n            customPrevIcon: AndroidResDrawable(name:\"ic_prev_custom\"),\n            customNextIcon: AndroidResDrawable(name:\"ic_next_custom\"),\n        )\n\n```\n\nAnd don't forget tell proguard to keep those resources for release mode\n\n(part Keeping Resources)\n\nhttps://sites.google.com/a/android.com/tools/tech-docs/new-build-system/resource-shrinking\n\n```xml\n\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources xmlns:tools=\"http://schemas.android.com/tools\"\ntools:keep=\"@drawable/ic_next_custom, @drawable/ic_prev_custom, @drawable/ic_pause_custom, @drawable/ic_play_custom, @drawable/ic_stop_custom\"/\u003e\n```\n\n### By Manifest\n\n1. Add your icon into your android's `res` folder (android/app/src/main/res)\n\n2. Reference this icon into your AndroidManifest (android/app/src/main/AndroidManifest.xml)\n\n```xml\n\u003cmeta-data\n     android:name=\"assets.audio.player.notification.icon\"\n     android:resource=\"@drawable/ic_music_custom\"/\u003e\n```\n\nYou can also change actions icons\n\n```\n\u003cmeta-data\n    android:name=\"assets.audio.player.notification.icon.play\"\n    android:resource=\"@drawable/ic_play_custom\"/\u003e\n\u003cmeta-data\n    android:name=\"assets.audio.player.notification.icon.pause\"\n    android:resource=\"@drawable/ic_pause_custom\"/\u003e\n\u003cmeta-data\n    android:name=\"assets.audio.player.notification.icon.stop\"\n    android:resource=\"@drawable/ic_stop_custom\"/\u003e\n\u003cmeta-data\n    android:name=\"assets.audio.player.notification.icon.next\"\n    android:resource=\"@drawable/ic_next_custom\"/\u003e\n\u003cmeta-data\n    android:name=\"assets.audio.player.notification.icon.prev\"\n    android:resource=\"@drawable/ic_prev_custom\"/\u003e\n```\n\n## Handle notification click (android)\n\nAdd in main\n\n```dart\nAssetsAudioPlayer.setupNotificationsOpenAction((notification) {\n    //custom action\n    return true; //true : handled, does not notify others listeners\n                 //false : enable others listeners to handle it\n});\n```\n\nThen if you want a custom action on widget\n\n```dart\nAssetsAudioPlayer.addNotificationOpenAction((notification) {\n   //custom action\n   return false; //true : handled, does not notify others listeners\n                 //false : enable others listeners to handle it\n});\n```\n\n## Custom actions\n\nYou can enable/disable a notification action\n\n```dart\nopen(AUDIO,\n   showNotification: true,\n   notificationSettings: NotificationSettings(\n       prevEnabled: false, //disable the previous button\n\n       //and have a custom next action (will disable the default action)\n       customNextAction: (player) {\n         print(\"next\");\n       }\n   )\n\n)\n```\n\n## Update audio's metas / notification content\n\nAfter your audio creation, just call\n\n```dart\naudio.updateMetas(\n       player: _assetsAudioPlayer, //add the player if the audio is actually played\n       title: \"My new title\",\n       artist: \"My new artist\",\n       //if I not provide a new album, it keep the old one\n       image: MetasImage.network(\n         //my new image url\n       ),\n);\n```\n\n## Bluetooth Actions\n\nYou have to enable notification to make them work\n\nAvailable remote commands :\n\n- Play / Pause\n- Next\n- Prev\n- Stop\n\n## HeadPhone Strategy\n\n(Only for Android for now)\n\nwhile opening a song/playlist, add a strategy\n\n```dart\nassetsAudioPlayer.open(\n   ...\n  headPhoneStrategy: HeadPhoneStrategy.pauseOnUnplug,\n  //headPhoneStrategy: HeadPhoneStrategy.none, //default\n  //headPhoneStrategy: HeadPhoneStrategy.pauseOnUnplugPlayOnPlug,\n)\n```\n\nIf you want to make it work on bluetooth too, you'll have to add the BLUETOOTH permission inside your AndroidManifest.xml\n\n```xml\n\u003cuses-permission android:name=\"android.permission.BLUETOOTH\" /\u003e\n```\n\n# ⛓ Play in parallel / simultaneously\n\nYou can create new AssetsAudioPlayer using AssetsAudioPlayer.newPlayer(),\nwhich will play songs in a different native Media Player\n\nThis will enable to play two songs simultaneously\n\nYou can have as many player as you want !\n\n```dart\n///play 3 songs in parallel\nAssetsAudioPlayer.newPlayer().open(\n    Audio(\"assets/audios/song1.mp3\")\n);\nAssetsAudioPlayer.newPlayer().open(\n    Audio(\"assets/audios/song2.mp3\")\n);\n\n//another way, with create, open, play \u0026 dispose the player on finish\nAssetsAudioPlayer.playAndForget(\n    Audio(\"assets/audios/song3.mp3\")\n);\n```\n\nEach player has an unique generated `id`, you can retrieve or create them manually using\n\n```dart\nfinal player = AssetsAudioPlayer.withId(id: \"MY_UNIQUE_ID\");\n```\n\n# 🗄️ Playlist\n\n```Dart\nassetsAudioPlayer.open(\n  Playlist(\n    audios: [\n      Audio(\"assets/audios/song1.mp3\"),\n      Audio(\"assets/audios/song2.mp3\")\n    ]\n  ),\n  loopMode: LoopMode.playlist //loop the full playlist\n);\n\nassetsAudioPlayer.next();\nassetsAudioPlayer.prev();\nassetsAudioPlayer.playlistPlayAtIndex(1);\n```\n\n## Audio Widget\n\nIf you want a more flutter way to play audio, try the `AudioWidget` !\n\n[![sample](./medias/audio_widget.gif)](https://github.com/florent37/Flutter-AssetsAudioPlayer)\n\n```dart\n//inside a stateful widget\n\nbool _play = false;\n\n@override\nWidget build(BuildContext context) {\n  return AudioWidget.assets(\n     path: \"assets/audios/country.mp3\",\n     play: _play,\n     child: RaisedButton(\n           child: Text(\n               _play ? \"pause\" : \"play\",\n           ),\n           onPressed: () {\n               setState(() {\n                 _play = !_play;\n               });\n           }\n      ),\n      onReadyToPlay: (duration) {\n          //onReadyToPlay\n      },\n      onPositionChanged: (current, duration) {\n          //onPositionChanged\n      },\n  );\n}\n```\n\nHow to 🛑 stop 🛑 the AudioWidget ?\n\nJust remove the Audio from the tree !\nOr simply keep `play: false`\n\n## 🎧 Listeners\n\nAll listeners exposes Streams\nUsing RxDart, AssetsAudioPlayer exposes some listeners as ValueObservable (Observable that provides synchronous access to the last emitted item);\n\n### 🎵 Current song\n\n```Dart\n//The current playing audio, filled with the total song duration\nassetsAudioPlayer.current //ValueObservable\u003cPlayingAudio\u003e\n\n//Retrieve directly the current played asset\nfinal PlayingAudio playing = assetsAudioPlayer.current.value;\n\n//Listen to the current playing song\nassetsAudioPlayer.current.listen((playingAudio){\n    final asset = playingAudio.assetAudio;\n    final songDuration = playingAudio.duration;\n})\n```\n\n### ⌛ Current song duration\n\n```Dart\n//Listen to the current playing song\nfinal duration = assetsAudioPlayer.current.value.duration;\n```\n\n### ⏳ Current position (in seconds)\n\n```Dart\nassetsAudioPlayer.currentPosition //ValueObservable\u003cDuration\u003e\n\n//retrieve directly the current song position\nfinal Duration position = assetsAudioPlayer.currentPosition.value;\n\nreturn StreamBuilder(\n    stream: assetsAudioPlayer.currentPosition,\n    builder: (context, asyncSnapshot) {\n        final Duration duration = asyncSnapshot.data;\n        return Text(duration.toString());\n    }),\n```\n\nor use a PlayerBuilder !\n\n```dart\nPlayerBuilder.currentPosition(\n     player: _assetsAudioPlayer,\n     builder: (context, duration) {\n       return Text(duration.toString());\n     }\n)\n```\n\nor Player Builder Extension\n\n```dart\n_assetsAudioPlayer.builderCurrentPosition(\n     builder: (context, duration) {\n       return Text(duration.toString());\n     }\n)\n```\n\n### ▶ IsPlaying\n\nboolean observable representing the current mediaplayer playing state\n\n```Dart\nassetsAudioPlayer.isPlaying // ValueObservable\u003cbool\u003e\n\n//retrieve directly the current player state\nfinal bool playing = assetsAudioPlayer.isPlaying.value;\n\n//will follow the AssetsAudioPlayer playing state\nreturn StreamBuilder(\n    stream: assetsAudioPlayer.isPlaying,\n    builder: (context, asyncSnapshot) {\n        final bool isPlaying = asyncSnapshot.data;\n        return Text(isPlaying ? \"Pause\" : \"Play\");\n    }),\n```\n\nor use a PlayerBuilder !\n\n```dart\nPlayerBuilder.isPlaying(\n     player: _assetsAudioPlayer,\n     builder: (context, isPlaying) {\n       return Text(isPlaying ? \"Pause\" : \"Play\");\n     }\n)\n```\n\nor Player Builder Extension\n\n```dart\n_assetsAudioPlayer.builderIsPlaying(\n     builder: (context, isPlaying) {\n       return Text(isPlaying ? \"Pause\" : \"Play\");\n     }\n)\n```\n\n### 🔊 Volume\n\nChange the volume (between 0.0 \u0026 1.0)\n\n```Dart\nassetsAudioPlayer.setVolume(0.5);\n```\n\nThe media player can follow the system \"volume mode\" (vibrate, muted, normal)\nSimply set the `respectSilentMode` optional parameter as `true`\n\n```dart\n_player.open(PLAYABLE, respectSilentMode: true);\n```\n\nhttps://developer.android.com/reference/android/media/AudioManager.html?hl=fr#getRingerMode()\n\nhttps://developer.apple.com/documentation/avfoundation/avaudiosessioncategorysoloambient\n\nListen the volume\n\n```dart\nreturn StreamBuilder(\n    stream: assetsAudioPlayer.volume,\n    builder: (context, asyncSnapshot) {\n        final double volume = asyncSnapshot.data;\n        return Text(\"volume : $volume\");\n    }),\n```\n\nor use a PlayerBuilder !\n\n```dart\nPlayerBuilder.volume(\n     player: _assetsAudioPlayer,\n     builder: (context, volume) {\n       return Text(\"volume : $volume\");\n     }\n)\n```\n\n### ✋ Finished\n\nCalled when the current song has finished to play,\n\nit gives the Playing audio that just finished\n\n```Dart\nassetsAudioPlayer.playlistAudioFinished //ValueObservable\u003cPlaying\u003e\n\nassetsAudioPlayer.playlistAudioFinished.listen((Playing playing){\n\n})\n```\n\nCalled when the complete playlist has finished to play\n\n```Dart\nassetsAudioPlayer.playlistFinished //ValueObservable\u003cbool\u003e\n\nassetsAudioPlayer.playlistFinished.listen((finished){\n\n})\n```\n\n### 🔁 Looping\n\n```Dart\nfinal LoopMode loopMode = assetsAudioPlayer.loop;\n// possible values\n// LoopMode.none : not looping\n// LoopMode.single : looping a single audio\n// LoopMode.playlist : looping the fyll playlist\n\nassetsAudioPlayer.setLoopMode(LoopMode.single);\n\nassetsAudioPlayer.loopMode.listen((loopMode){\n    //listen to loop\n})\n\nassetsAudioPlayer.toggleLoop(); //toggle the value of looping\n```\n\n### 🏃 Play Speed\n\n```Dart\nassetsAudioPlayer.setPlaySpeed(1.5);\n\nassetsAudioPlayer.playSpeed.listen((playSpeed){\n    //listen to playSpeed\n})\n\n//change play speed for a particular Audio\n\nAudio audio = Audio.network(\n    url,\n    playSpeed: 1.5\n);\nassetsAudioPlayer.open(audio);\n```\n\n### 🎙️ Pitch\n\n```Dart\nassetsAudioPlayer.setPitch(1.2);\n\nassetsAudioPlayer.pitch.listen((pitch){\n    //listen to pitch\n})\n\n//change pitch for a particular Audio\n\nAudio audio = Audio.network(\n    url,\n    pitch: 1.2\n);\nassetsAudioPlayer.open(audio);\n```\n\n# Error Handling\n\nBy default, on playing error, it stop the audio\n\nBUT you can add a custom behavior\n\n```dart\n_player.onErrorDo = (handler){\n  handler.player.stop();\n};\n```\n\nOpen another audio\n\n```dart\n_player.onErrorDo = (handler){\n  handler.player.open(ANOTHER_AUDIO);\n};\n```\n\nTry to open again on same position\n\n```dart\n_player.onErrorDo = (handler){\n  handler.player.open(\n      handler.playlist.copyWith(\n        startIndex: handler.playlistIndex\n      ),\n      seek: handler.currentPosition\n  );\n};\n```\n\n# Network Policies (android/iOS/macOS)\n\nAndroid only allow HTTPS calls, you will have an error if you're using HTTP,\ndon't forget to add INTERNET permission and seet `usesCleartextTraffic=\"true\"` in your **AndroidManifest.xml**\n\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest ...\u003e\n    \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n    \u003capplication\n        ...\n        android:usesCleartextTraffic=\"true\"\n        ...\u003e\n        ...\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\niOS only allow HTTPS calls, you will have an error if you're using HTTP,\ndon't forget to edit your **info.plist** and set `NSAppTransportSecurity` to `NSAllowsArbitraryLoads`\n\n```\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\u003cdict\u003e\n    \u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n```\n\nTo enable http calls on macOs, you have to add input/output calls capabilities into `info.plist`\n\n```\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\u003cdict\u003e\n    \u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n\u003ckey\u003eUIBackgroundModes\u003c/key\u003e\n\u003carray\u003e\n    \u003cstring\u003eaudio\u003c/string\u003e\n    \u003cstring\u003efetch\u003c/string\u003e\n\u003c/array\u003e\n\u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\nand in your\n\n`Runner/DebugProfile.entitlements`\n\nadd\n\n```\n\u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\nComplete `Runner/DebugProfile.entitlements`\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n\t\u003ckey\u003ecom.apple.security.app-sandbox\u003c/key\u003e\n\t\u003ctrue/\u003e\n\t\u003ckey\u003ecom.apple.security.cs.allow-jit\u003c/key\u003e\n\t\u003ctrue/\u003e\n\t\u003ckey\u003ecom.apple.security.network.server\u003c/key\u003e\n\t\u003ctrue/\u003e\n\t\u003ckey\u003ecom.apple.security.network.client\u003c/key\u003e\n\t\u003ctrue/\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n```\n\n# 🎶 Musics\n\nAll musics used in the samples came from https://www.freemusicarchive.org/\n","funding_links":["https://ko-fi.com/FlorentChampigny","https://github.com/sponsors/florent37","https://ko-fi.com/A160LCC'"],"categories":["组件","Dart","Media [🔝](#readme)","Components"],"sub_categories":["媒体","Media"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FFlutter-AssetsAudioPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorent37%2FFlutter-AssetsAudioPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FFlutter-AssetsAudioPlayer/lists"}