Posts

Showing posts with the label api

HTML5 video capture from browser: error with "stop() not a function"

A quick blog post about recent changes in the MediaStream API support in modern browsers. I had previously developed a function allowing users to capture images from their webcam, based on tutorials found on the web. Here was my code to initialize the capture canvas: function CaptureImageBeginCapture () { CaptureImageCanvas = $ ( "#ImageCaptureCanvas" )[ 0 ]; var videoObj = { "video" : true }, errBack = function (error) { console . log ( "Video capture error: " , error. code ); }; CaptureImageVideo = $ ( "#ImageCapturePreviewFrame" )[ 0 ]; CaptureImageContext = CaptureImageCanvas . getContext ( "2d" ); // Put video listeners into place if ( navigator .getUserMedia) { // Standard navigator .getUserMedia( videoObj , function (stream) { CaptureImageStream = stream; CaptureImageVideo . src = stream; CaptureImageVideo . play (); }, errBack ); } else if ( n...

Shanghai Air Quality Index Widget (from US Embassy data)

Image
I live in Shanghai and air pollution is a major concern, especially in institutions such as schools or hospitals. It is important to give proper directives to children and elder: when the air pollution reaches a certain threshold, they should stay inside as much as possible and avoid any form of physical exercise outside. There are mainly two indices for air quality in Shanghai: the Chinese government's data and the official website of the US Consulate in Shanghai . The latter is based on an RSS feed updated every hour. In order to facilitate the display and comprehension of the data from that RSS feed, I have designed a widget (running under Windows XP/Vista/7/8) that is meant to display Shanghai's air quality index in real time - again, based on official data from the US Embassy. The widget was designed to be ran on display monitors that stay on 24/7, so it displays at the topmost  - it always shows on top regardless of other windows. The data is automatically refreshe...