38
White Master 1 Flash Runtime Globalization Team Introduction to Flash Runtime Mobile Features Introduction to Flash Runtime Mobile Features Flash Runtime Globalization Team Hao Wu, Yi Zhai

Flash runtime on mobile

Embed Size (px)

Citation preview

Page 1: Flash runtime on mobile

White Master

1

Flash Runtime Globalization Team

Introduction to Flash Runtime Mobile Features

Introduction to Flash Runtime Mobile Features

Flash Runtime Globalization Team

Hao Wu, Yi Zhai

Page 2: Flash runtime on mobile

2

1. Features of Flash Runtime on Mobile

Accelerometer

GPS

Camera

Stage Video

Device Speaker Control

2. Workshop – Native Extension

Page 3: Flash runtime on mobile

3

Page 4: Flash runtime on mobile

4

The Accelerometer class dispatches events based on activity detected by the device's motion sensor. This data represents the device's location or movement along a 3-dimensional axis.

Page 5: Flash runtime on mobile

5

var accelerometer:Accelerometer;

if(Accelerometer.isSupported){

accelerometer = new Accelerometer();

accelerometer.addEventListener(AccelerometerEvent.UPDATE,

updateHandler);

}

private function updateHandler (e:AccelerometerEvent):void{

trace(e.accelerationX);

trace(e.accelerationY);

trace(e.accelerationZ);

trace(e.timestamp)

}

Page 6: Flash runtime on mobile

6

Page 7: Flash runtime on mobile

7

Page 8: Flash runtime on mobile

8

The Geolocation class dispatches events in response to the device's location sensor.

Page 9: Flash runtime on mobile

9

var geolocation:Geolocation;

if(Geolocation.isSupported){

geolocation = new Geolocation();

if(!geolocation.muted){

geolocation.setRequestedUpdateInterval(10000);

geolocation.addEventListener(GeolocationEvent.UPDATE,updateHandler);

}

}

private function updateHandler(e:GeolocationEvent):void{

trace(e.longitude);

trace(e.latitude);

trace(e.altitude); //Other properties: heading, speed, timestamp

} //horizaontalAccuracy, VerticalAccuracy,

Page 10: Flash runtime on mobile

10

Page 11: Flash runtime on mobile

11

Page 12: Flash runtime on mobile

12

CameraUI

The CameraUI class allows you to capture a still image or video using the default camera application on a device.

CameraRoll

The CameraRoll class allows you to access image data in the system media library or "camera roll."

Page 13: Flash runtime on mobile

13

if (CameraUI.isSupported){

myCam = new CameraUI();

myCam.addEventListener(MediaEvent.COMPLETE, onComplete);

myCam.launch(MediaType.IMAGE);

}

if (CameraRoll.supportsBrowseForImage){

roll = new CameraRoll();

roll.addEventListener(MediaEvent.SELECT,onMediaSelect);

roll.browseForImage();

}

Page 14: Flash runtime on mobile

14

Page 15: Flash runtime on mobile

15

Page 16: Flash runtime on mobile

16

Page 17: Flash runtime on mobile

17

The StageVideo object uses the device's hardware acceleration capabilities, if available, to display live or recorded video in an application. Hardware acceleration capabilities are available on most devices

Page 18: Flash runtime on mobile

18

VideoStatus.ACCELERATER VideoStatus.SOFTWARE

StageVideo 最佳性能 使用GPU解码并合成 使用软件解码,用GPU合成

Video 使用硬件GPU解码,软件合成 最差的情况 使用软件解码并合成

Page 19: Flash runtime on mobile

19

private static const FILE_NAME:String = "media/Test_original.mp4";

var sv:StageVideo;

var nc:NetConnection;

var ns:NetStream;

nc = new NetConnection();

nc.connect(null);

ns = new NetStream(nc); stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);

Page 20: Flash runtime on mobile

20

private function onStageVideoState(event:StageVideoAvailabilityEvent):void{

// Detect if StageVideo is available and decide what to do in toggleStageVideo

toggleStageVideo(available = inited = (event.availability == StageVideoAvailability.AVAILABLE));

}

private function toggleStageVideo(on:Boolean):void{

sv = stage.stageVideos[0];

sv.attachNetStream(ns);

ns.play(FILE_NAME);

}

Page 21: Flash runtime on mobile

21

Page 22: Flash runtime on mobile

22

Page 23: Flash runtime on mobile

23

Ear Piece

Speaker Phone

Page 24: Flash runtime on mobile

24

Feature summary Enable mobile app to toggle between earpiece and speakerphone

AIR 2.7 > AIR 3.0 No way to choose two speaks Easily access different speakers All audio play back through media speaker

Enable the VOIP telephony

Enumerate all the speakers attached to device on mobile and desktop

Use cases New Adobe Directory/Connect for Android, with VoIP feature More AIR-based enterprise apps, integrating Flash Media Gateway

Page 25: Flash runtime on mobile

25

AudioPlaybackMode Speakerphone in use

iOS Category be used

Audio Output Route (Headphone)

Media 0 MediaPlayback Device Speaker (Headphone)

Media 1 MediaPlayback Device Speaker (Headphone)

AudioPlaybackMode Speakerphone in use iOS Category be used Audio Output Route (Headphone)

Voice 0 PlayAndRecord Phone Receiver (Headphone)

Voice 1 PlayAndRecord Device Speaker

Page 26: Flash runtime on mobile

26

Play_button.addEventListener(MouseEvent.CLICK, playMusic);

function playMusic(e:Event):void

{

SoundMixer.audioPlaybackMode = “media”;

SoundMixer.useSpeakerphoneForVoice = false;

if(! playing)

{

sc = music.play(pos);

playing = true;

}

}

Page 27: Flash runtime on mobile

27

Microphone.isSupported Microphone.getMicrophone() Microphone.getEnhancedMicrophone() Microphone.setUseEchoSuppression() Microphone.setSilenceLevel(silenceLevel, timeout) SampleDataEvent.SAMPLE_DATA Microphone.activityLevel

Page 28: Flash runtime on mobile

28

Front-facing camera support

Android Market licensing integration

Captive runtime support for Android

Stagetext

Flash Access on Android

Mobile background app audio playback for iOS

Enable HW Video decoding on various chipsets

Native Extensions on Mobile

Page 29: Flash runtime on mobile

29

NativeExtension

Page 30: Flash runtime on mobile

30

The native extensions feature enables the addition of third-party, native-code backed ActionScript APIs to AIR applications.

A actionscript Library with Native Code implementation

Normal apps NativeExtension apps

Page 31: Flash runtime on mobile

31

Enhance Performance

Zxing:ActionScript 2000ms, Android 10ms

Expand functions

Autofocus for camera , Vibration …

Page 32: Flash runtime on mobile

32

Page 33: Flash runtime on mobile

33

Page 34: Flash runtime on mobile

34

Page 35: Flash runtime on mobile

35

Page 36: Flash runtime on mobile

36

An Android Project

Provide Native Implementation for Native Extension

A Flex Library Project

Provide ActionScript API for Native Extension

Page 37: Flash runtime on mobile

37

Ane file

A set of Actionscript with native code implementation

A Flex Mobile Project

Use the ane

Page 38: Flash runtime on mobile

38