plugins for xamarinxamarinuniversity.blob.core.windows.net... · speaka“hello world”f;...

35

Upload: others

Post on 25-May-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 2: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

JamesMontemagnoDeveloper Evangelist, Xamarin

[email protected] http://motzcod.es @JamesMontemagno

Page 3: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Shared C# codebase • 100% native API access • High performance

iOS C# Windows C#Android C#

Shared C# Mobile

Page 4: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 5: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

MapKit UIKit iBeacon CoreGraphics CoreMotion

System.Data System.Windows System.Numerics System.Core System.ServiceModel

System.Net System System.IO System.Linq System.Xml

Page 6: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 7: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Shared C# Backend

Page 8: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

UI+APIs UI + APIsUI + APIs

BatteryGPSLightsNotificationsSettingsText To Speech

BatteryGPSLightsNotificationsSettingsText To Speech

BatteryGPSLightsNotificationsSettingsText To Speech

Page 9: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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)﴿;

}

Page 10: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 11: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

public async void Speak(﴾string text)﴿ {

SpeechSynthesizer synth = new SpeechSynthesizer(﴾)﴿; await synth.SpeakTextAsync(﴾text)﴿;

}

SpeechSynthesizer

Page 12: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

public interface ITextToSpeech{

void Speak (﴾string text)﴿; }

ITextToSpeech

Page 13: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 14: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

TextToSpeech

Speak(﴾“Hello World”)﴿;

AVSpeechSynthesizer SpeechSynthesizer

Page 15: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Common API

Page 16: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 17: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 18: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Xamarin.iOS Xamarin.Android

Page 19: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 20: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 21: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 22: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 23: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 24: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 25: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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

Page 26: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Implementation

PCL -‐ Abstraction (﴾Interface)﴿

Implementation Implementation

NuGet Package

Page 27: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 28: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Implementation

Abstraction PCL (﴾Interface)﴿

Implementation Implementation

NuGet Package

Page 29: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 30: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 31: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 32: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 33: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference
Page 34: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

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/

Page 35: Plugins for Xamarinxamarinuniversity.blob.core.windows.net... · SpeakA“Hello World”F; AVSpeechSynthesizer SpeechSynthesizer. Common API. Xamarin.iOS Xamarin.Android. Reference

Thank you.

JamesMontemagnoDeveloper Evangelist, Xamarin

[email protected] http://motzcod.es @JamesMontemagno

Questions?