Skip to content

Instantly share code, notes, and snippets.

@kfiil

kfiil/MainView.js

Last active Jun 10, 2016
Embed
What would you like to do?
Play iOS system sound(Uno and Native JavaScript Modules) in button click event handler
var play = require("SoundPlayer").Play;
function buttonPlayClicked(){
play();
}
//RELOAD
module.exports = {
buttonPlayClicked: buttonPlayClicked
};
<App Theme="Basic">
<DockPanel Background="{backgroundColor}">
<SoundPlayer ux:Global="SoundPlayer" />
<JavaScript File="MainView.js"/>
<Button Clicked="{buttonPlayClicked}" Text="Play"/>
</DockPanel>
</App>
using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;
using iOS.AudioToolbox;
using iOS.Foundation;
public class SoundPlayer : NativeModule
{
public SoundPlayer()
{
AddMember(new NativeFunction("Play", (NativeCallback)Play));
}
static object Play(Context c, object[] args)
{
//Sounds http://iphonedevwiki.net/index.php/AudioServices
global::iOS.AudioToolbox.Functions.AudioServicesPlaySystemSound(1310);
return null;
}
}
{
"RootNamespace":"",
"Packages": [
"Fuse.Animations",
"Fuse.BasicTheme",
"Fuse.Controls",
"Fuse.Designer",
"Fuse.Drawing",
"Fuse.Drawing.Primitives",
"Fuse.Effects",
"Fuse.Elements",
"Fuse.Entities",
"Fuse.Gestures",
"Fuse.Navigation",
"Fuse.Shapes",
"Fuse.Triggers",
"Fuse.Reactive",
"Fuse.Android",
"Fuse.Desktop",
"Fuse.iOS",
"Fuse.Vibration",
"FuseCore",
"Uno.Collections",
"Uno.Geometry",
"ObjC",
"Experimental.iOS",
"Fuse.Scripting",
"Fuse.Reactive"
],
"Icon": "",
"Includes": [
"*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment