What’s new for Windows 8 Devs Part 3

Download Report

Transcript What’s new for Windows 8 Devs Part 3

demo
// Application manifest capabilities required to access camera and microphone
<Capabilities>
<DeviceCapability Name="webcam" />
<DeviceCapability Name="microphone" />
</Capabilities>
<body>
<p id=“message”></p>
<img id=“imagedisplay” />
<script type=“text/javascript”>
// Step 1: Invoke the camera capture UI for snapping a photo
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
captureUI.captureFileAsync(Windows.Media.CameraCaptureUI.Mode.photo).
then(function(capturedItem) {
if (capturedItem) {
// Step 2: Display the photo
document.getElementById(“imagedisplay”).src = URL.createObjectURL(capturedItem);
} else {
document.getElementById(“message”).innerHTML = “User didn’t capture a photo”;
}
});
</script>
</body>
<body>
<p id=“message”></p>
<video id=“videoplayback” />
<script type=“text/javascript”>
// Step 1: Invoke the camera capture UI for record a video
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
captureUI.captureFileAsync(Windows.Media.CameraCaptureUI.Mode.video).
then(function(capturedItem) {
if (capturedItem) {
// Step 2: Display the video
document.getElementById(“videoplayback”).src = URL.createObjectURL(capturedItem);
}
});
</script>
</body>
demo
function initializeMediaCapture() {
// Step 1: create Media Capture object
var mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
mediaCaptureMgr.initializeAsync().then(
function (op) {
// Step 2: Update the source of <video>
document.getElementById(“preview").src = URL.createObjectURL(mediaCaptureMgr,
false);
// Step 3: Start displaying the camera feed
document.getElementById(“preview").play();
});
}
Windows.Storage.KnownFolders.videosLibrary.createFileAsync("cameraCapture.mp4",
Windows.Storage.CreationCollisionOption.generateUniqueName).then(function (newFile)
{
storageFile = newFile;
encodingProfile= Windows.Media.MediaProperties.MediaEncodingProfile.createMp4(
Windows.Media.MediaProperties.VideoEncodingQuality.auto);
mediaCaptureMgr.startRecordToStorageFileAsync(encodingProfile, storageFile).then(
function (result) {
// recording, eventually stop it.
// mediaCaptureMgr.stopRecordAsync();
},
errorHandler);
},
errorHandler);
Windows.Storage.KnownFolders.videosLibrary.createFileAsync("cameraCapture.m4a",
Windows.Storage.CreationCollisionOption.generateUniqueName).then(function (newFile) {
storageFile = newFile;
encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.createM4a(
Windows.Media.MediaProperties.AudioEncodingQuality.auto);
mediaCaptureMgr.startRecordToStorageFileAsync(encodingProfile, storageFile).then(
function (result) {
//recording, eventually stop it..
mediaCaptureMgr.stopRecordAsync();
},
errorHandler);
},
errorHandler);
// Application manifest capabilities required
// to access Geolocation in your app
<Capabilities>
<DeviceCapability Name=“location" />
</Capabilities>
var loc;
loc = new Windows.Devices.Geolocation.Geolocator();
//One-time
loc.getGeopositionAsync().then(getPositionHandler);
loc.addEventListener("positionchanged", function ()
{ getPositionHandler (
args.position);});
function getPositionHandler(pos) {
var lat = pos.coordinate.latitude;
var long = pos.coordinate.longitude;
var acc = pos.coordinate.accuracy;
}
demo
var accelerometer;
accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();
accelerometer.addEventListener("readingchanged",onAccReadingChanged);
function onAccReadingChanged(e) {
var accelX = e.reading.accelerationX;
var accelY = e.reading.accelerationY;
var accelZ = e.reading.accelerationZ;
}
ST Microelectronics eMotion
Development Board




function initializeProximityDevice() {
var proximityDevice =
Windows.Networking.Proximity.ProximityDevice.getDefault();
proximityDevice.addEventListener("devicearrived", proximityDeviceArrived);
proximityDevice.addEventListener("devicedeparted",
proximityDeviceDeparted);
}
function proximityDeviceArrived() {
id("messageDiv").innerHTML += "Proximate device arrived. id = " +
device.deviceId + "<br />";
}
function proximityDeviceDeparted() {
id("messageDiv").innerHTML += "Proximate device departed. id = " +
device.deviceId + "<br />";
}
demo
“Code for touch, get mouse and pen for free!”
API surface
CSS Properties
DOM Attributes
DOM Events
Scrolling
overflow
-ms-scroll-rails
-ms-scroll-snap-x
-ms-scroll-snap-y
-ms-scroll-chaining
-ms-scroll-boundary
scrollLeft
scrollTop
scroll
Zooming
-ms-content-zooming
-ms-content-zoomboundary
-ms-content-zoom-snap
msContentZoomFactor
MSContentZoom
Both
Snap-points
MSManipulationStateChanged
-ms-scroll-snap-type
-ms-scroll-snap-point-x