Audio_service: Play Local Audio

Created on 10 Jun 2020  路  10Comments  路  Source: ryanheise/audio_service

How can we play local audio with this plugin?

1 backlog Awaiting response question

Most helpful comment

if I call Local assets audio file in MediaItem like this
id: "assets/audio/1591766340463.mp3"
it doen't know that url. any way to call the local assets.
How could I load Audio from Assets?
I hope you will know my question.
Thank you.

All 10 comments

I think this is plausibly a "frequently asked question", although the answer is rather straightforward:

This plugin does not play audio.

This plugin only wraps around your existing audio code to allow it to work in the background, but it doesn't care how you actually play the audio. It's up to you to use other plugins to play the audio. This is what I have tried to explain in the README file, although hopefully a FAQ entry will help.

If you look at the example, you'll see it uses the just_audio plugin to play audio, so a starting point would be for you to consult the documentation of that plugin rather than this plugin (which doesn't play audio). You will find the answers there.

Sorry for my confusion question. I want to know that, if we want to play local or asset audio ,
how can we set the audio file url in id's of MediaItem insted of fetching the remote url.
MediaItem(
id: "https://s3.amazonaws.com/scifri-episodes/scifri20181123-episode.mp3",
album: "Science Friday",
title: "A Salute To Head-Scratching Science",
artist: "Science Friday and WNYC Studios",
duration: Duration(milliseconds: 5739820),
artUri:
"https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg",
)

The id is just a unique id for your media item. As per the documentation:

/// Metadata about an audio item that can be played, or a folder containing
/// audio items.
class MediaItem {
  /// A unique id.
  final String id;

It is not required to be a URL.

if i placed asset file url . or local url. it doen't read it.how do I solve that?

it doen't read it.

If I add this question to the FAQ, I need it to be a clear question. Can you clarify what each of your two "it" references refer to?

if I call Local assets audio file in MediaItem like this
id: "assets/audio/1591766340463.mp3"
it doen't know that url. any way to call the local assets.
How could I load Audio from Assets?
I hope you will know my question.
Thank you.

Can you rephrase your question without using the word "it"? That way I will hopefully know what you mean.

You can use setAsset() instead of setUri(), like this: setAsset("assets/audio/1591766340463.mp3");

image
why is the local file not loaded? the picture in the curtain does not appear.

I'm sorry this issue is closed. But I will improve the documentation if you submit a documentation request describing which part of the documentation i should improve. Please click on "New issue", and then click the appropriate link from that page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

getmmg picture getmmg  路  3Comments

austinbyron picture austinbyron  路  4Comments

AhmadAbdollah picture AhmadAbdollah  路  6Comments

Drabuna picture Drabuna  路  7Comments

trighomautumnatg picture trighomautumnatg  路  7Comments