Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F;...
Transcript of Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F;...
JamesMontemagnoDeveloper Evangelist, Xamarin
[email protected] http://motzcod.es @JamesMontemagno
Shared C# codebase • 100% native API access • High performance
iOS C# Windows C#Android C#
Shared C# Mobile
Microsoft.Phone Microsoft.Networking Windows.Storage Windows.Foundation Microsoft.Devices
System.Data System.Windows System.Numerics System.Core System.ServiceModel
System.Net System System.IO System.Linq System.Xml
MapKit UIKit iBeacon CoreGraphics CoreMotion
System.Data System.Windows System.Numerics System.Core System.ServiceModel
System.Net System System.IO System.Linq System.Xml
Text-‐to-‐speech ActionBar Printing Framework Renderscript NFC
System.Data System.Windows System.Numerics System.Core System.ServiceModel
System.Net System System.IO System.Linq System.Xml
Shared C# Backend
UI+APIs UI + APIsUI + APIs
BatteryGPSLightsNotificationsSettingsText To Speech
BatteryGPSLightsNotificationsSettingsText To Speech
BatteryGPSLightsNotificationsSettingsText To Speech
AVSpeechSynthesizer public void Speak (﴾string text)﴿ {
var speechSynthesizer = new AVSpeechSynthesizer (﴾)﴿; var speechUtterance = new AVSpeechUtterance (﴾text)﴿ {
Rate = AVSpeechUtterance.MaximumSpeechRate/4, Voice = AVSpeechSynthesisVoice.FromLanguage (﴾"en-‐US")﴿, Volume = 0.5f, PitchMultiplier = 1.0f
}; speechSynthesizer.SpeakUtterance (﴾speechUtterance)﴿;
}
AVSpeechSynthesizer TextToSpeech speaker; string toSpeak; public void Speak (﴾string text)﴿ {
toSpeak = text; if (﴾speaker == null)﴿ {
speaker = new TextToSpeech (﴾ctx, this)﴿;} else{
var p = new Dictionary<string,string> (﴾)﴿; speaker.Speak (﴾toSpeak, QueueMode.Flush, p)﴿;
}} public void OnInit (﴾OperationResult status)﴿ {
//… more stuff}
TextToSpeech
public async void Speak(﴾string text)﴿ {
SpeechSynthesizer synth = new SpeechSynthesizer(﴾)﴿; await synth.SpeakTextAsync(﴾text)﴿;
}
SpeechSynthesizer
public interface ITextToSpeech{
void Speak (﴾string text)﴿; }
ITextToSpeech
TextToSpeech
Speak(﴾“Hello World”)﴿;
AVSpeechSynthesizer SpeechSynthesizer
Common API
Xamarin.iOS Xamarin.Android
Reference Reference
Portable Class Library
API Contract
Built in IoC
Shared Code
Models
View Models
VM Calls Method
Native Android App
Views
Call into View Model
Native iOS App
Views
Call Into View Model
Reference Reference
Portable Class Library
API Contract
Built in IoC
Shared Code
Models
View Models
VM Calls Method
Native Android App
Views
Call into View Model
Native iOS App
Views
Call Into View Model
Android Library
API Implementation
Built in IoC
iOS Library
API Implementation
Built in IoC
Reference Reference
Shared Code
Models
View Models
VM Calls Method
Native Android App
Views
Call into View Model
Native iOS App
Views
Call Into View Model
API Contract
Android Library
API Implementation
Built in IoC
API Contract
iOS Library
API Implementation
Built in IoC
Implementation
PCL -‐ Abstraction (﴾Interface)﴿
Implementation Implementation
NuGet Package
Implementation
Abstraction PCL (﴾Interface)﴿
Implementation Implementation
NuGet Package
http://github.com/xamarin/plugins
http://bit.ly/plugin-‐templates
http://developer.xamarin.com
http://log.paulbetts.org/the-‐bait-‐and-‐switch-‐pcl-‐trick/
http://www.michaelridland.com/xamarin/best-‐practices-‐using-‐xamarin-‐plugins/
Thank you.
JamesMontemagnoDeveloper Evangelist, Xamarin
[email protected] http://motzcod.es @JamesMontemagno
Questions?