Skip to content

Instantly share code, notes, and snippets.

View seksenov's full-sized avatar

Kiril Seksenov seksenov

  • Salesforce
  • Seattle
View GitHub Profile
if(typeof Windows != 'undefined') {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
//Set the format of the picture that's going to be captured (.png, .jpg, ...)
captureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png;
//Pop up the camera UI to take a picture
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
// Do something with the picture
});
}
@seksenov
seksenov / codepenACUR.xml
Created June 9, 2015 15:49
Application Content URI Rules Example
StartPage="http://codepen.io/seksenov/pen/wBbVyb/?editors=101">
<uap:ApplicationContentUriRules>
<uap:Rule Match="http://codepen.io/seksenov/pen/wBbVyb/?editors=101" Type="include" WindowsRuntimeAccess="all"/>
<uap:Rule Match="http://*.codepen.io/" Type="include" WindowsRuntimeAccess="all"/>
</uap:ApplicationContentUriRules>
@seksenov
seksenov / windowsFeatureDetect.js
Last active August 29, 2015 14:24
Feature detecting for notifications on Windows
if (typeof Windows !== 'undefined' &&
typeof Windows.UI !== 'undefined' &&
typeof Windows.UI.Notifications !== 'undefined') {
//Call Windows.UI.Notifications
}
function cameraCapture() {
if(typeof Windows != 'undefined') {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
//Set the format of the picture that's going to be captured (.png, .jpg, ...)
captureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png;
//Pop up the camera UI to take a picture
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
// Do something with the picture
});
}
@seksenov
seksenov / fileDownload.js
Created December 8, 2015 23:59
This gist shows how a web app running as a Hosted Web App with Windows API Access is able to download and
'use strict'
var client = null;
document.addEventListener("DOMContentLoaded", init);
function init() {
var btn = document.getElementById("saveFile");
btn.addEventListener("click", () => downloadAndSave("./img/detroitSkyline.jpg"));
}
'use strict';
var systemMediaControls;
(function () {
// Add the event listener to handle Windows activated event
if (typeof Windows !== 'undefined') {
systemMediaControls = Windows.Media.SystemMediaTransportControls.getForCurrentView();
systemMediaControls.addEventListener("buttonpressed", systemMediaControlsButtonPressed, false);
<video id="mediaVideo" src="img/Westminster_high.mp4" controls></video>
if (typeof Windows !== 'undefined') {
var systemMediaControls = Windows.Media.SystemMediaTransportControls.getForCurrentView();
systemMediaControls.addEventListener("buttonpressed", systemMediaControlsButtonPressed, false);
systemMediaControls.isPlayEnabled = true;
systemMediaControls.isPauseEnabled = true;
systemMediaControls.isStopEnabled = true;
systemMediaControls.playbackStatus = Windows.Media.MediaPlaybackStatus.closed;
}
document.addEventListener("DOMContentLoaded", function () {
var videoElement = document.getElementById("mediaVideo");
videoElement.addEventListener("pause", mediaPaused);
videoElement.addEventListener("playing", mediaPlaying);
videoElement.addEventListener("ended", mediaEnded);
});
function mediaPlaying() {
// Update the SystemMediaTransportControl state.
systemMediaControls.playbackStatus = Windows.Media.MediaPlaybackStatus.playing;
}
function mediaPaused() {
// Update the SystemMediaTransportControl state.
systemMediaControls.playbackStatus = Windows.Media.MediaPlaybackStatus.paused;
}
function mediaEnded() {
// Update the SystemMediaTransportControl state.