# How to get local .mp3 file

**URL:** <https://forums.fusetools.com/t/how-to-get-local-mp3-file/2311>\
**Category:** How-to Discussions\
**Created:** [May 11, 2016, 7:14pm UTC](https://forums.fusetools.com/t/how-to-get-local-mp3-file/2311 "2016-05-11T19:14:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Wallander](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@Victor\_Wallander](https://forums.fusetools.com/u/Victor_Wallander)\
**Post date:** [May 11, 2016, 7:14pm UTC](https://forums.fusetools.com/t/how-to-get-local-mp3-file/2311/1 "2016-05-11T19:14:09Z")

</div>

Hello

How do you include a mp3 file into the bundle? Or how do you make this work with a local mp3 file:

```auto
    static object Load(Context c, object[] args)
        {

            var player = _players[(int)args[0]];

            var filePath = args[1] as string;

            debug_log "Load file: "+filePath;

            foreach(var bf in Uno.IO.Bundle.AllFiles)
            {

                //debug_log bf.SourcePath;
            }

            //filePath = "sound.mp3"; File only included in project - not working
            //filePath = "http://www.wallandermedia.se/sound.mp3&quot;; Works 

            player.Load(filePath);

            return null;
        }

```

---

<div class="post-metadata">

**Author:** ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)\
**Post date:** [May 13, 2016, 3:01pm UTC](https://forums.fusetools.com/t/how-to-get-local-mp3-file/2311/2 "2016-05-13T15:01:59Z")

</div>

Hi!

It looks like you are using the MediaPlayer code from [https://www.fusetools.com/community/forums/howto\_discussions/audio\_player\_implentation\_with\_fusejs?page=1](https://www.fusetools.com/community/forums/howto_discussions/audio_player_implentation_with_fusejs?page=1)

In the player code we are using Java/ObjectiveC code for the implementation, so we have to fish out some stuff that they want.

I have added the code that is needed to load bundlefiles for this particular case in Android/iOS

```auto
interface IMediaPlayer
{
    void Load(string filePath);
    void Load(BundleFile bundleFile);
    void Play();
}

extern(Android) class AndroidMediaPlayer : IMediaPlayer
{
    public void Load(BundleFile bundleFile)
    {
        LoadBundle(_mediaPlayerHandle, bundleFile.BundlePath);
    }

    [Foreign(Language.Java)]
    static void LoadBundle(Java.Object handle, string bundlePath)
    @{
        try
        {
            android.content.res.AssetFileDescriptor afd = @(Activity.Package).@(Activity.Name)
                .GetRootActivity()
                .getAssets()
                .openFd(assetName);

            ((android.media.MediaPlayer)handle).setDataSource(
                afd.getFileDescriptor(),
                afd.getStartOffset(),
                afd.getLength());

            ((android.media.MediaPlayer)handle).prepare();
        }
        catch (java.lang.Exception e)
        {
            android.util.Log.d("android player", "Failed to load: " + e.getMessage());
        }
    @}
}

extern(iOS) class iOSMediaPlayer : IMediaPlayer
{
    public void Load(BundleFile bundleFile)
    {
        var absolutePath = GetBundleAbsolutePath(bundleFile.BundlePath);
    }

    [Foreign(Language.ObjC)]
    static string GetBundleAbsolutePath(string bundlePath)
    @{
        return [[[NSBundle mainBundle] URLForResource:bundlePath withExtension:@""] absoluteString];
    @}
}

```

Let me know if you have any further questions 🙂
