Skip to content

Instantly share code, notes, and snippets.

View seksenov's full-sized avatar

Kiril Seksenov seksenov

  • Salesforce
  • Seattle
View GitHub Profile
function playMedia() {
var media = document.getElementById("mediaVideo");
media.play();
}
function pauseMedia() {
var media = document.getElementById("mediaVideo");
media.pause();
}
function stopMedia() {
var media = document.getElementById("mediaVideo");
@seksenov
seksenov / SMTCButtonPressed.js
Created February 27, 2016 00:05
Handle SMTC Event
function systemMediaControlsButtonPressed(eventIn) {
var mediaButton = Windows.Media.SystemMediaTransportControlsButton;
switch (eventIn.button) {
case mediaButton.play:
playMedia();
break;
case mediaButton.pause:
pauseMedia();
break;
case mediaButton.stop:
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.
document.addEventListener("DOMContentLoaded", function () {
var videoElement = document.getElementById("mediaVideo");
videoElement.addEventListener("pause", mediaPaused);
videoElement.addEventListener("playing", mediaPlaying);
videoElement.addEventListener("ended", mediaEnded);
});
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;
}
<video id="mediaVideo" src="img/Westminster_high.mp4" controls></video>
'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);
@seksenov
seksenov / changeAppTitleBarColors.js
Created December 10, 2015 23:51 — forked from Gr8Gatsby/changeAppTitleBarColors.js
This Gist shows how to set the application titlebar colors. There is a helper function that accepts an HTML hexString and converts it to an RGBA color object for Windows.
/*
This function expects two hexStrings and relies on hexStrToRGBA to convert
to a JSON object that represents RGBA for the underlying Windows API to
understand.
Examples of valid values:
setAppBarColors('#FFFFFF','#000000');
setAppBarColors('#FFF','#000');
setAppBarColors('FFFFFF','000000');
setAppBarColors('FFF','000');
@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"));
}
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
});
}