Upload
howard-wu
View
1.052
Download
2
Tags:
Embed Size (px)
Citation preview
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
2
1. Features of Flash Runtime on Mobile
Accelerometer
GPS
Camera
Stage Video
Device Speaker Control
2. Workshop – Native Extension
3
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.
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)
}
6
7
8
The Geolocation class dispatches events in response to the device's location sensor.
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,
10
11
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."
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();
}
14
15
16
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
18
VideoStatus.ACCELERATER VideoStatus.SOFTWARE
StageVideo 最佳性能 使用GPU解码并合成 使用软件解码,用GPU合成
Video 使用硬件GPU解码,软件合成 最差的情况 使用软件解码并合成
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);
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);
}
21
22
23
Ear Piece
Speaker Phone
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
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
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;
}
}
27
Microphone.isSupported Microphone.getMicrophone() Microphone.getEnhancedMicrophone() Microphone.setUseEchoSuppression() Microphone.setSilenceLevel(silenceLevel, timeout) SampleDataEvent.SAMPLE_DATA Microphone.activityLevel
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
29
NativeExtension
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
31
Enhance Performance
Zxing:ActionScript 2000ms, Android 10ms
Expand functions
Autofocus for camera , Vibration …
32
33
34
35
36
An Android Project
Provide Native Implementation for Native Extension
A Flex Library Project
Provide ActionScript API for Native Extension
37
Ane file
A set of Actionscript with native code implementation
A Flex Mobile Project
Use the ane
38