Skip to content

Instantly share code, notes, and snippets.

View DaveVoyles's full-sized avatar

Dave Voyles DaveVoyles

View GitHub Profile
@DaveVoyles
DaveVoyles / InitializeVideoStream - Get User Media
Created May 29, 2015 15:53
InitializeVideoStream - Get User Media
// initializeVideoStream() - Callback function when getUserMedia() returns successfully with a mediaStream object
// 1. Set the mediaStream on the video tag
// 2. Use 'srcObject' attribute to determine whether to use the standard-based API or the legacy version
var initializeVideoStream = function(stream) {
mediaStream = stream;
var video = document.getElementById('videoTag');
if (typeof (video.srcObject) !== 'undefined') {
video.srcObject = mediaStream;
@DaveVoyles
DaveVoyles / InitializeVideoStream - Get User Media
Created May 29, 2015 15:53
InitializeVideoStream - Get User Media
// initializeVideoStream() - Callback function when getUserMedia() returns successfully with a mediaStream object
// 1. Set the mediaStream on the video tag
// 2. Use 'srcObject' attribute to determine whether to use the standard-based API or the legacy version
var initializeVideoStream = function(stream) {
mediaStream = stream;
var video = document.getElementById('videoTag');
if (typeof (video.srcObject) !== 'undefined') {
video.srcObject = mediaStream;
@DaveVoyles
DaveVoyles / gist:a772f9f19a4cd93f6814
Created May 29, 2015 15:50
savePhoto - GetUserMedia
// savePhoto() - Function invoked when user clicks on the canvas element
// 1. If msSaveBlob is supported, get the photo blob from the canvas and save the image file
// 2. Otherwise, set up the download attribute of the anchor element and download the image file
var savePhoto = function() {
if (photoReady) {
var canvas = document.getElementById('canvasTag');
if (navigator.msSaveBlob) {
var imgData = canvas.msToBlob('image/jpeg');
navigator.msSaveBlob(imgData, 'myPhoto.jpg');
/*x-radial-buttons.html*/
var currentAccent = 'en-US';
var accentArr = ['en-US', 'en-GB', 'es-ES'];
getCurrentAccent: function () {
return currentAccent;
},
/* Main.js*/
form.addEventListener('submit', function (e) { window.pokemonApp.sayTheName(e) });
// Say the text when button is pressed
pokemonApp.sayTheName = function (e) {
e.preventDefault();
playerElement.speak();
console.log(radialButtons.intValue);
};
input.addEventListener('input', function (e) {
playerElement.setAttribute('text', input.value);
xPokemon.name = input.value;
});
<!-- Container for Web Components content -->
<aside>
<h3>Enter the name of a Pokemon!</h3>
<form id="player-form" class="pure-form">
<input id="player-input" type="text" value="pikachu">
<button id="player-submit" class="pure-button pure-button-primary">Speak!</button>
<button id="btn-change-accent" class="pure-button pure-button-primary">Change Accent</button>
<!-- Text-to-speech -->
<voice-player id="player-element" accent="es-ES" text=""></voice-player>
</form>
@DaveVoyles
DaveVoyles / gist:75958df1b2e03518892b
Last active August 29, 2015 14:17
radial element index.html element
<article>
<header>
<h1>Gotta say 'em all! </h1>
<p>This web app takes advantage of Web Components and Polymer to enable new HTML features in the browser.</p>
<p>
In this particular case, we are using <a href="https://github.com/passy/x-pokemon" target="_blank">
the x-pokemon web component </a> to pull the images from a database, as well as the
<a href="http://zenorocha.github.io/voice-elements/" target="_blank">voice-elements web component</a> to speak the name of the pokemon we entered.
</p>
<p>
<script>
(function () { // IIFE makes attributes global
/* -- Global Attributes ------------------------------------------------ */
var currentAccent = 'en-US';
var accentArr = ['en-US', 'en-GB', 'es-ES'];
Polymer('x-radial-buttons', {
/* -- Methods --------------------------------------------------- */
getCurrentAccent: function () {
return currentAccent;
},
@DaveVoyles
DaveVoyles / gist:b4808d8a50535d588b34
Created March 13, 2015 12:15
radial buttons incomplete
<link rel="import" href="bower_components/polymer/polymer.html" >
<link rel="import" href="../paper-radio-group/paper-radio-group.html" >
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<polymer-element name="x-radial-buttons">
<!-- Shadow DOM -->
<template>
<style>
#paper_radio_group {
position: relative;