# Recording audio - possible as of yet?

**URL:** <https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046>\
**Category:** Feature Suggestions\
**Created:** [May 6, 2015, 1:28pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046 "2015-05-06T13:28:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yyyannag](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@yyyannag](https://forums.fusetools.com/u/yyyannag)\
**Post date:** [May 6, 2015, 1:28pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/1 "2015-05-06T13:28:12Z")

</div>

API is pretty scarce right now, don’t know if it’s because that’s all there is to it right now, or it’s imcomplete…

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [May 6, 2015, 10:45pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/2 "2015-05-06T22:45:51Z")

</div>

Hi! For what platform ?

There is no abstraction API but you can use the Android and iOS APIs directly.

---

<div class="post-metadata">

**Author:** ![yyyannag](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@yyyannag](https://forums.fusetools.com/u/yyyannag)\
**Post date:** [May 7, 2015, 3:11pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/3 "2015-05-07T15:11:06Z")

</div>

I was hoping both, I guess Android first 🙂

How do I use native API on the fuse platform? This could be very well a good solution, since I’m pretty proficient with Java 🙂

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [May 7, 2015, 4:25pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/4 "2015-05-07T16:25:20Z")

</div>

Add a package reference to the `Android` package. Then just write

```auto
var recorder = new Android.android.media.MediaRecorder()

```

🙂

See [http://developer.android.com/reference/android/media/MediaRecorder.html](http://developer.android.com/reference/android/media/MediaRecorder.html)

---

<div class="post-metadata">

**Author:** ![yyyannag](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@yyyannag](https://forums.fusetools.com/u/yyyannag)\
**Post date:** [May 7, 2015, 6:26pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/5 "2015-05-07T18:26:49Z")

</div>

Thanks, but I don’t see android.media in the edit reference… or is Android enough?

---

<div class="post-metadata">

**Author:** ![Anders\_Schau\_Knatten](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_schau_knatten/32/41_2.png) [@Anders\_Schau\_Knatten](https://forums.fusetools.com/u/Anders_Schau_Knatten)\
**Post date:** [May 7, 2015, 6:32pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/6 "2015-05-07T18:32:20Z")

</div>

You just need the `Android` package, it contains all the `android.*` namespaces.

---

<div class="post-metadata">

**Author:** ![yyyannag](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@yyyannag](https://forums.fusetools.com/u/yyyannag)\
**Post date:** [May 7, 2015, 6:48pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/7 "2015-05-07T18:48:32Z")

</div>

Thanks, I created a new project, and added one simple class called Helper (I added the Android reference):

```auto
using Uno;
using Uno.Collections;
using Fuse;

namespace Recorder
{
    public class Helper
    {
        Android.android.media.MediaRecorder recorder;
        public Helper() {
            recorder = new Android.android.media.MediaRecorder();
        }
    }
}

```

when compiling, I got an error:

```auto
EUNKNOWN: Android.android.media.MediaRecorder.ctor() cannot be used in this context because it is marked with Uno.Compiler.ExportTargetInterop.ExportConditionAttribute

```

Any idea what I’m doing wrong? I haven’t even began to use this class…

---

<div class="post-metadata">

**Author:** ![Joao\_Abecasis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/joao_abecasis/32/221_2.png) [@Joao\_Abecasis](https://forums.fusetools.com/u/Joao_Abecasis)\
**Post date:** [May 7, 2015, 7:09pm UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/8 "2015-05-07T19:09:59Z")

</div>

I think the problem here is that Android bindings can only be used on an Android build. You might be building for Fuse’s simulator where they aren’t available.

When using platform-specific code, such us when you use bindings to native APIs, you’ll need to attribute some classes or functions with `[ExportCondition("Android")]` or inside `if (defined(Android)) { ... }` blocks.

Typically, if you’re targetting multiple platforms, as we expect you will, you’ll define a common interface that is implemented specifically for each platform, the implementations of which would be tagged with the `ExportCondition` attribute. You’d also have a factory method for the interface that specifically instantiates the appropriate class inside a platform-specific `if (defined(Android)) { ... }` block.

I have an example building up to this, but with only an iOS implementation, you can look at here: [https://gist.github.com/biochimia/74e16bdf8f57cf5ba3de](https://gist.github.com/biochimia/74e16bdf8f57cf5ba3de)

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [May 8, 2015, 9:32am UTC](https://forums.fusetools.com/t/recording-audio-possible-as-of-yet/1046/9 "2015-05-08T09:32:04Z")

</div>

Added a fix to make the error message more easy to understand. In the next version, it will say:

```auto
'Android.android.media.MediaRecorder' can only be used in 'Android' export. Consider adding [ExportCondition("Android")] to your class, or put the code inside 'if (defined(Android)) { ... }'

```
