domingo, 2 de septiembre de 2012

Play Sound on Hover – Web Audio API Edition

Play Sound on Hover – Web Audio API Edition:
I got an email from a Notary Sojac who saw my tutorial on playing a sound on hover. In that tutorial we had to resort to some fairly hackish behavior to get the sound to react nicely to our events. Notary Sojac had an update to make the existing code work better, but more importantly, was looking into the Web Audio API for doing stuff like this. I didn't even know that was a thing. Turns out it's not controlling HTML5 audio elements, it's deeper level access than that.
The following is a guest post by Notary Sojac explaining all that.
We're all impressed with the capabilities of HTML5 canvas. The idea of creating a standardized and logical way of performing 2d drawing operations opened the door to an amazing new world where one programmer could learn one language and develop amazing products that could be deployed to all relevant platforms! Think about how critical this is for a moment. Now think about who would want an amazing graphics application that has a buggy, glitchy sound system that only makes sounds moments after you clicked and sometimes forgets to make sounds all together? That's the kind of product you get (especially in mobile platforms) if you go the HTML5 <audio> element route. It's better in desktop browsers, but unfortunately will never be perfected due to reasons beyond the scope of this article. But as of now, for the desktop, there is still hope. And there is hope in the future for mobile applications as well. That hope is named...

Web Audio API

The web audio API is designed for high precision and low level access. You can literally write bits of data to the samples. I'm not 100% sure what a sample is, but I think it has to do with air pressure against a microphone (aka, the microphone's driver position) at a single moment in time. That's pretty low level if you ask me. In Google Chrome, all audio functions are handled by a separate thread to ensure non-wonkyness.
On August 21st, Mozilla began making public the fact that they're dropping their original, pioneering "Audio Data API" and are beginning to implement Google's "Web Audio API" in their browser. But that means, at the time of this writing, you'll need to use a fallback for Firefox.
You can hear a great deal of good information from this Google I/O talk by Chris Wilson:

How To Use It

Unfortunately you need to use a lot more JavaScript with the Web Audio API than you do with plain old HTML5 audio elements, but often times the precision of the Web Audio API is imperative.
First we need to load the sound, which can be done with a function like this:
// you'll put the PCM audio in here
var audioBuffer = null;  
var context = new webkitAudioContext();

function loadDogSound(url, variableToBufferSound) {
  var request = new XMLHttpRequest();
  request.open('GET', url, true);
  request.responseType = 'arraybuffer';

  // Decode asynchronously
  request.onload = function() {
    context.decodeAudioData(request.response, function(buffer) {
      variableToBufferSoundIn = buffer;
    }, onError);
  }
  request.send();
}
Then we play the buffer, with a function like this:
function playSound(buffer) {

  // creates a sound source
  var source = context.createBufferSource();

  // tell the source which sound to play
  source.buffer = buffer;          

  // connect the source to the context's destination (the speakers)           
  source.connect(context.destination);       
  
  // play the source now
  source.noteOn(0);                          
}
That's a heck of a lot more code than we need as designers, just trying to play simple mouseover sound effects. Luckily, I snapped together a little JavaScript framework for using the Web Audio API.
With this new API, all one needs to do is:
  1. Create an AudioContext
  2. Load a sound into that AudioContext
  3. Play the sound
All of these steps are one liners! Fallbacks to good old HTML5 are included!
<script src="javascripts/webAudioApiForDesigners.js"></script>

<script>
// 1
var context = initializeNewWebAudioContext();

// 2
context.loadSound('audio/beep.ogg', 'beep');

$("#nav-one a")
  .mouseenter(function() {
    // 3
   context.playSound('beep');
  });
</script>
View Demo

List of reasons why HTML5 audio elements may be a bad choice

  • Wonky latency problems where sounds are heard at wrong times
  • Unexplainable popping sounds when playing multiple sound files at once
  • Limit to number of HTML5 audio elements that can play simultaneously

Reasons why HTML5 might be more suitable to your project

  • Very simple and straightforward to use
  • Can play background music just fine
  • Eventually (wild guess: no sooner than within the next 3 years) the bugs will be ironed out of these sorts of html DOM elements

More Information

HTML5 Rocks has a solid introduction.
Play Sound on Hover – Web Audio API Edition is a post from CSS-Tricks

JavaScript Slideshow Code + CSS3 Transitions

JavaScript Slideshow Code + CSS3 Transitions:
JavaScript Slideshow Code
TinyFader2 is a 2KB JavaScript slider code that is completely configurable through robust options. It is an upgrade to the previous TinyFader version adding a number of requested features and making additional improvements. It gracefully degrades without JavaScript support and is totally customizable using CSS.
Here are the current features:
  • CSS3 hardware transition support for Firefox and Webkit browsers
  • Automatic or manual slide rotation
  • Option to resume play after interruption
  • Toggle to pause auto play on slide hover
  • Set the initial slide index with a parameter
  • Pass a navigation ID of a list and have the script bind either click or hover events for navigating the slideshow
  • Ability to move to previous or next slide
  • Functions to play and pause the automatic slideshow
  • Parameter to set the transition duration
Other improvements include setting the opacity to 0 on slides besides the current one, cycling the z-index, improving code readability, upgrading the codebase to HTML5, and a handful of other tweaks.
To initialize the script use the following:
var ss = new TINY.fader.init("ss", {
 id: "slides", // ID of the slideshow list container
 position: 0, // index where the slideshow should start
 auto: 0, // automatic advance in seconds, set to 0 to disable auto advance
 resume: true, // boolean if the slideshow should resume after interruption
 navid: "pagination", // ID of the slide nav list
 activeClass: "current", // active class for the nav relating to current slide
 pauseHover: true, // boolean if the slideshow should pause on slide hover
 navEvent: "click", // click or mouseover nav event toggle
 duration: .25 // duration of the JavaScript transition in seconds, else the CSS controls the duration, set to 0 to disable fading
});
The first parameter is the variable name used for the object instance. This script has been tested in all major browsers and is available free of charge for both personal or commercial projects under the GNU GPL v3.0 license.

Click here for the demo.



Click to download
Downloaded 3 Times

lunes, 23 de julio de 2012

A New Collection of Free HTML5 and CSS3 Templates

A New Collection of Free HTML5 and CSS3 Templates:



  
Professionally designed and neatly coded templates always make life easier for developers, not only because they save time, but also for the effort they save. Since web development is an ever expanding field, it is important for developers to keep their work up to date with the latest changes. HTML5 and CSS3 templates are there to make your websites future proof and make them even more accessible.
In this round up, we are presenting a brilliant collection of some fresh and free HTML5 and CSS3 templates that you can download today. With these templates, you can also learn how to code your websites in HTML5 and CSS3. So, enjoy looking into this collection we have compiled for you.

The Templates

Template for Powerful Business Startup ( Demo | Download )
The visually pleasing layout is the first thing that catches the attention when you look at this theme, but it’s certainly not the last. Along with cool graphic elements and hand-written typography, this free website template will provide you with the functionality you need for a good start for your online business.
Screenshot
Animated Neoarts ( Demo | Download )
This is a modern and elegantly designed web template suitable for Design/Studio websites. All-in-One page with an animated theme.
Screenshot
Vintage – HTML Template ( Demo | Download )
This is a responsive blog template that comes with a retro touch. You can use this template for a stylish portfolio.
Screenshot
Template for Restaurant Business ( Demo | Download )
This free website template features an attractive and functional design, which is important for attracting visitors’ attention and making the time they spend at your site pleasant. Geared towards a restaurant, this high-grade theme comes with a stylish layout in an elegant color scheme, with a jQuery slider, and a nice gallery for the images you have.
Screenshot
Simpler ( Demo | Download )
As the name indicates, the template is relatively simpler than the other templates presented in this collection. It has a fixed layout which is made in HTML5.
Screenshot
Free Template for Spa Salon with Zoomer Effect ( Demo | Download )
If your business deals with offering a wide variety of beauty services, try this nicely done ready-made template for starting up your project. The pleasant color scheme turns out to be a good background for the wonderful images from your collection. The neatly arranged content blocks in the main part of the theme are intended to present all the necessary information in an effective way.
Screenshot
CSS3 Design One ( Demo | Download )
CSS3 Design One is a simple two column fixed width template, with a jQuery drop-down menu, jQuery image fader and working PHP contact form. It utilizes @font-face, and CSS3 rounded corners / text shadow.
Screenshot
Zen ( Demo | Download )
This free website template is best suited for the personal blog pages. The template has been designed by using HTML5 and looks visually appealing.
Screenshot
Template for Web Design Studio ( Demo | Download )
Though this theme can be used for many other purposes, it was primarily designed for web design studios. It is a user friendly and visually appealing web template.
Screenshot
Caja ( Demo | Download )
This creatively designed web template is ideal for those who want to make certain files available for download on their websites as well as want to showcase their work.
Screenshot
Scenic Photo Two ( Demo | Download )
Scenic Photo Two is a simple two column fixed width template, with a jQuery drop-down menu and scenic photographic background image. With a working PHP contact form, it utilizes lots of CSS3 features.
Screenshot
Watercolor ( Demo | Download )
This template comes with a fixed layout however you can choose from 4 different skins that are available. It is a friendly XHTML/CSS template.
Screenshot
Responsive Brownie ( Demo | Download )
A brilliant responsive HTML5 template aimed at businesses and portfolios.
Screenshot
Simple ( Demo | Download )
Simple is a neat and clean web template that offers more 7 page layouts, jQuery functionality, 2 Cufon fonts to choose from, loads of background patterns, as well as one sprite file image.
Screenshot
Immaculate 2 ( Demo | Download )
This free HTML5 website template is suitable for blogs and personal websites.
Screenshot
Folder ( Demo | Download )
This is a responsive HTML5 template that can be used with any device and browser size without any problem. This is an ideal template for creative showcases and businesses.
Screenshot
PhotoArtWork2 ( Demo | Download )
PhotoArtWork2 comes with 3 different image galleries, a jQuery drop down menu, as well as a functional PHP contact form. This template is suited for photography related and portfolios websites.
Screenshot
Left ( Demo | Download )
This web template is designed in HTML5 and offers more than 6 page layouts with a unique skin system that can create a new skin appearance within minutes.
Screenshot
PhotoArtWork2_reverse ( Demo | Download )
This is another version of PhotoArtWork2 that is a complete web template with easy to customize options.
Screenshot
Muro ( Demo | Download )
This is another brilliantly designed web template that comes with 3 different skins, 7 page layouts as well as jQuery functionality.
Screenshot
Torn ( Demo | Download )
Torn is an XHTML web template that offers 5 pre-defined skins and 7 page layouts along with jQuery functionality.
Screenshot
Template for Horse Club ( Demo | Download )
Horse Club is one of the free website templates created by the Template Monster team.
Screenshot
CSS3 Seascape Two ( Demo | Download )
This template offers a 2 column fixed width template with a jQuery drop down menu, image transitions and PHP contact form.
Screenshot
Photo Style Two ( Demo | Download )
Photo Style Two web template also offers a jQuery drop down menu, image fader and PHP contact form.
Screenshot
Template for Business Project ( Demo | Download )
If you want your website to look as efficient and professional as possible then you should opt for this free web template. It focuses on the main points of your business and highlight them to grab the attention of the visitors.
Screenshot
Connoisseur ( Demo | Download )
With this web template, you can easily set your website apart from your competitors. This free website template is suitable for all those websites that pertain to fine arts, cuisine, dining, etc.
Screenshot

More on Page Two

Many more templates await, over on page two. So head on over and check them out!

HTML5 Tutorials for Keeping Your Design Skills Tight

HTML5 Tutorials for Keeping Your Design Skills Tight:



  
With the growing number of HTML5 tutorials available to help designers and developers get a better handle on this language, it can get a bit tricky sorting through them to find what you are truly looking for. And as the capabilities of this language expand, it is important to keep up with the many ways to harness the full power of HTML5. Today, we hope to help you on that journey.
Below is a collection of handy HTML5 tutorials and resources that will teach you the basic ins and outs of the language, along with many, much more specific techniques. Take a look down through them and start boning up on HTML5!

Learn the Basics

What is HTML5? Infographic covers what it is, and why it’s useful. It also goes into where it’s supported. While not technically a tutorial, this is still a helpful resource to keep on hand.

HTML5 Tutorial.com is a great place for beginners to get their feet wet. The site is set up for those who have little to no knowledge of the language, and promises to get them ready to write and edit a site by hand.

HTML5 for Web Developers is an awesome work in progress, that is written with web developers in mind (cutting out the unnecessary vendor specific bits of the spec). Comprehensive and growing, this HTML5 specification is fantastic for beginners or those looking to refresh.

HTML5 Doctor is a site that anyone looking to sharpen their skills should know about. Their article archive alone is like an entire course on HTML5 and worth your while to take a look through.

HTML5 Pocket Book is just that. A short and sweet intro into the language. This printable fold-up pocket guide is a good cheat sheet of sorts for beginners to keep handy.

Getting Specific

Toying With the HTML5 File System API is a tutorial that explores this new element of HTML5, and the basics of this new API. Going over the most common file system tasks.

Have A Field Day With HTML5 Forms seeks to make you share the author’s love of using HTML5 to create much needed web forms. With the aid of some CSS techniques, you will have a fully styled and ready to use form in your arsenal.

Cross-Browser HTML5 Placeholder Text is a tutorial that will allow you to use HTML5 to fill any unfocused sections of your forms to have placeholder text. For browsers where this is not supported yet, there is a jQuery fallback in place.

Code a Backwards Compatible, One Page Portfolio with HTML5 and CSS3 is a solid tutorial that will teach you the basics of this sort of build. While it is built using HTML5 and CSS3, it takes older browsers and their lack of support into consideration.

How To Build A Real-Time Commenting System is a nifty tutorial that will take you through using HTML5 to craft a commenting system that works with users in real-time, adding that fluidity and freshness to your site.

Design & Code a Cool iPhone App Website in HTML5 is not just for someone looking to promote an app, though that is where it is aimed. The tutorial will take the user through constructing a promotional site using HTML5 and a bit of style in CSS3.

How HTML5 Aids Mobile Financial App Development explains many of the new tags that are available in the language for building financial based applications.

HTML5 localStorage is divided into four parts and seeks to break down and fully explain the specifics of this aspect of the language. For those who do not know much about HTML5 localStorage, or those looking to know more, this is a great place to turn.

Add HTML5 video to your site will give you the tools to embed vids into your pages without having to rely on plugins or anything but your code. Again, there are fallbacks in place with this system for older browsers (flash based).

Touch The Future: Create An Elegant Website With HTML5 And CSS3 offers readers a brief overview of both languages before diving into a well structured tutorial that will have you building your own site by the end.

A Non-Responsive Approach to Building Cross-Device Webapps is a well thought out approach to serving up device specific builds, without simply using media queries to accomplish a purely aesthetic rearrangement of web elements.

HTML5 File Uploads with jQuery is a useful tutorial that uses the new HTML5 API’s to facilitate a jQuery based ‘upload center’ with drag and drop capabilities.

Create Vector Masks using the HTML5 Canvas teaches users to use the handy canvas tag in HTML5 with a bit of clipping to help shape more stylish images for your site.

Build your own HTML5 3D engine once again uses HTML5′s canvas tag, though this time with a little bit of Javascript to fashion a 3D rendering engine.

HTML5 Grayscale Image Hover offers users the means to dynamically clone colors within an image to turn it into grayscale, without an image editor. Instead, once again, HTML5′s canvas tag plays along with jQuery to make this happen.

“Mobifying” Your HTML5 Site is a tutorial that is dedicated to keeping your website mobile ready, and using HTML5 to get you there. With the focus on mobile ready these days, this tutorial might just hold the solutions you have been looking for.

Build your First Game with HTML5 calls on the power of Box2D and the ever-awesome canvas tag in HTML5 to craft a playable app.

Making a Beautiful HTML5 Portfolio uses both the Quicksand plugin, and the power of jQuery to build this stylish HTML5 based site to display your works.

All For Now

That is all on this end, folks, but that doesn’t mean the road ends here. We know there are more tutorials out there, and some thoughts that you may have on the ones we have shared. So take a moment and leave us a comment telling or directing us to the tutorials that really stand out to you.
(rb)