Thursday, January 14, 2016

What are Media Capture and Streams and How Do I Use Them?

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

When using web technologies to develop apps, be it on the web or mobile, there are times when you would want to use local multimedia devices, such as microphones or video cameras. An example would be to allow users to stream or take photos of themselves from the local video camera. To give you a little background, audio/video capture and streaming on the web had been largely dependent on browser plugins (Flash or Silverlight). With HTML5 and browsers pulling the plug on browser plugins, HTML5, hailed as the savior, brought to the web access to device capabilities, from Geolocation (GPS) and WebGL (GPU) to the Web Audio API (audio hardware), amongst many others.

These powerful features expose high level JavaScript APIs that talk to the system's underlying hardware capabilities.

Let’s start with HTML Media Capture which, per specification, is defined as a form extension that facilitates the access to a device's media capture mechanism, which can be a camera, or microphone or even a file within the upload control.

At its heart the Media Capture extends the HTMLInputElement interface with a capture attribute. A basic example would be: .

This capture attribute makes the request to use the media capture tool (camera, microphone, etc.) for capturing media on the spot.

Here is simple declarative example to illustrate its use. The following shows an HTML form using capture alongside the accept attribute, which gives hints on the preferred MIME type for the user to capture media.

<input type="file" accept="image/*" capture>

HTML Media Capture extension was specifically designed to be simple and declarative, and covers a subset of the media capture functionality of the web platform. Nevertheless, this HTML specification does not provide detailed author control over capture nor does it allow access to real-time media streams from the hosting device. HTML Media Capture was the first shot at standardizing media capture on the web. It reuses the file input element and works by overloading it and adding new values for the accept parameter. So basically, it works like a charm but it only allows you to record a media file or take a snapshot in time. Where Media Capture fell short was the ability to achieve real-time effects such as rendering live webcam data to a <canvas> element and apply some WebGL filters on it.

And thus, we have Media Capture and Streams.

Media Capture and Streams is actually a set of JavaScript APIs. These APIs allow local media (audio and video) to be requested from a platform. In other words, it provides access to the user's local audio and video input/output devices.

More specifically, we have the MediaStream API, which provides the means to control where multimedia stream data is consumed, and provides some control over the devices that produce the media. Additionally, the MediaStream API exposes information about the devices that are able to capture and render media.

Why is it important? Here’s a history lesson for the future generations that might take this for granted. The media (Audio/Video) capture capability has been the "Nirvana" of web development for some time. Historically, we had to rely on browser plugins (Flash or Silverlight) to achieve this. Then came HTML5 to the rescue. HTML5 brought powerful features that allow access to device hardware natively from Geolocation (GPS) to WebGL (GPU) and much more. These features which are now baked into the browser expose high level JavaScript APIs that sit on top of the device’s hardware capabilities.

So, why would we use it becomes obvious.

One of the most important methods in this API is getUserMedia() and it’s the gateway into that set of APIs. getUserMedia() provides the means to access the user's local camera/microphone stream.

Nevertheless, Feature detecting is the best way to check for its support, either directly if(navigator.getUserMedia) or using modernizer if(Modernizr.getusermedia).

Continue reading %What are Media Capture and Streams and How Do I Use Them?%


by Rami Sarieddine via SitePoint

Getting M.E.A.N. With Trello and Zapier

When speaking of workflow tools, there's no doubt that both Trello and Zapier play a significant role in the lives of many developers. Trello manages tasks while Zapier automates them. This makes this pair a powerful combination. By the end of this article, we'll have wired up a form that posts to a MongoDB instance set up on MongoHQ. Additionally, we'll tie it to Zapier, so that it creates a new Trello card every time there's an addition into our users' collections.

Introducing Trello

Trello is a task manager that excels in providing assets such as markdown support or shortcuts. It makes managing tasks an overall easier process. Here at SitePoint, we rely on Trello each day in order to effectively develop content from an idea to an article. Throughout the editorial process, we make use of a number of different boards, which are an essential part of Trello. We have a card for each article. These cards often include outlines, links, and other things relevant to the subject. With that in mind, there are tons of different ways in which Trello can provide benefits in the form of organizing information relevant to your life.

Today, we're going to make use of Trello, combine it with Zapier, and create something that will amaze you. By the end of this tutorial, we'll have a form that creates a card from the information passed into it. Below we can see an example of a card that will be generated using the data sent to our form.

Trello-Card

For those of you who don't have a Trello account, you can create one in a few minutes. When registered, we'll create a new board and a list soon, and we'll generate items inside this list in the form of Trello cards.

Generator Fullstack

We'll use a generator fullstack to build this application. A basic knowledge of the M.E.A.N. stack would be beneficial but it isn't necessary to complete this tutorial. Those of you who are new to the M.E.A.N. stack will soon see how easy it is to build a full stack application with the help of this Yeoman generator.

Continue reading %Getting M.E.A.N. With Trello and Zapier%


by Thomas Greco via SitePoint

JSONForms – Javascript Library to Submit Forms as JSON

JSONForms is a javascript library for submitting form data as JSON. With this plugin you can convert any form into a structured JSON object.


by via jQuery-Plugins.net RSS Feed

It’s Time to Rethink Vendor Prefixes in CSS

The -webkit- prefix is now so dominant across CSS on the web that some websites fail to work properly without it. While this is clearly a sign of less than ideal practices by developers over the past few years, it has led to quite an unfortunate but almost necessary move by Mozilla. By either Firefox 46 or 47 (released either in April or May 2016), Mozilla plan to implement support for a series of non-standard -webkit- prefixes to improve Firefox's compatibility with a -webkit prefixed (and often mobile) web.

This is not a new idea, Microsoft Edge supports a series of -webkit- prefixes too to ensure compatibility. Opera already began implementing -webkit- prefixes in 2012 and have since moved to the WebKit based Blink engine.

The W3C and browser vendors did not intend for vendor prefixes to be used on production websites:

"Official W3C policy states that you shouldn't really use experimental properties in production code, but people do, as they want to make sites look cool and keep on the cutting edge." - W3C page on optimizing content for different browsers

However, developers everywhere wanted to use them to access the latest features as soon as they could. While prefixes have caused a bit of a mess with WebKit's dominance, I think they succeeded in helping the web move forward quite rapidly.

The approach by Mozilla and Microsoft is likely to be harmless to most websites. Most websites online will have already included -moz- prefixes or will find that the updates by Mozilla improve their website compatibility with no action required. As professional web developers though, we do need to be thorough and understand that there are outlier results that may occur on some designs. You may already know which of your creations could break with this update.

Developers, it is clearly time to rethink your approach to prefixes and test those websites.

The Prefixes Involved

There are a range of -webkit- prefixes Mozilla might look to include. From what I've gathered, Mozilla aren't looking to match Edge's list of supported -webkit- prefixes, as not all of these are likely to be necessary to ensure Mozilla's Gecko layout engine compatibility with the broader web.

The prefixes Mozilla is likely to approach according to their wiki page on Compatibility/Mobile/Non Standard Compatibility includes the following:

  • -webkit-flexbox
  • -webkit- prefixed gradients
  • -webkit-transforms
  • -webkit-transitions
  • -webkit-appearance
  • -webkit-background-clip
  • -webkit-device-pixel-ratio
  • -webkit-animation
  • -webkit-border*

Some other features may be impacted too such as @-webkit-keyframes.

Cross Browser Testing Will Be Crucial

If you are a web developer out there who left out -moz- prefixes to avoid the need to test newer CSS features on Firefox — let's assume you were on a tight deadline and the client forced your hand — you are going to need to retest that site in Firefox 46 or 47. These versions of Firefox will be out in either in April or May, so you have a bit of time to plan ahead.

Continue reading %It’s Time to Rethink Vendor Prefixes in CSS%


by Patrick Catanzariti via SitePoint

Getting Started With Telerik AppBuilder

Cybeer Bar

Brewery

Oh man, just when you thought you'd seen it all. Digital agency Leavingstone have created this fun interactive One Pager that digitally pours a beer - using your phone. Yup, you have to see it to believe it. If you're reading this on your mobile, here is a video demo. Looking forward to the fun future when we'll be interacting more with websites like this.

by Rob Hope via One Page Love

Everything You Need to Know About Setting Your Prices

In everyday life, you probably don’t spend a ton of time questioning why items cost what they do—you simply choose whether or not to buy them depending on your needs, desires, and budget.

But it turns out, a huge amount of thought goes into each and every price tag you see. And if you’re not making incredibly strategic decisions about your own product’s price, well, you’re sabotaging your business.

Here’s what you should consider before putting a dollar value on your goods or services.

The Three Basic Pricing Models

There are three foundational approaches to calculating prices: cost-based, competition-based, and value-based.

Cost-Based Pricing

This method is the simplest. Start with how much you want to make on each product, then add how much it takes to make and distribute that product. The sum is your price.

Although cost-based pricing will give you the margins you’re looking for, most people agree it’s not effective because it’s not tied to customer demand, market conditions, or the product’s true value.

Competition-Based Pricing

Using this approach, you analyze how much other companies are charging for similar products and choose competitive prices. If you use this model, your product needs differentiating features to give customers a reason to buy it.

If you’re in a well-established industry where consumers are familiar with how much the traditional product costs, competition-based pricing may be the way to go.

Many apps rely on competition-based pricing. For example, productivity apps Fantastical 2 and Clear are both priced at $4.99.

Value-Based Pricing

Value-based pricing is the most popular and effective. Of course, it’s also the hardest to nail down. To determine your value-based price, you figure out how much money or value your product generates for the user in the long run, then take a fraction of that.

For a simplified example, let’s say that you’re selling an email replacement tool that helps companies recover $7,000 in productive hours each month. Ten percent is a reasonable cut, so you set your monthly price at $700.

Obviously, if you’re selling something that’s not directly functional, value-based pricing becomes even more nebulous.

Get around this by gathering a sample of potential customers (i.e., people in your target demographic) and asking them if they’d buy your product at X price, at Y price, at Z price, etc. You’ll be able to generate a rough bell curve of the percentage of consumers who will buy at each price point. In general, the “value” of your product is at the peak of the curve. (That doesn’t mean that’s what your price should be, however—more on that in a bit!)

Pricing Goals

Even after you’ve found the most suitable pricing model for your product, you need to factor in your company’s business plan.

Make Money Fast

There are a couple situations that may demand bringing in as much profit as you can as quickly as you can. First, if you’re bootstrapping it (which means running your company with no outside money), you’ll need to generate profit right away. Second, if you’re looking to attract funding, showing profitability is a great way to convince VCs or angels that your startup will be a good investment. (Note: You don’t always need to be in the black to get investors excited—Snapchat and Facebook were worth billions of dollars before they ever turned a profit!)

Drive Your Revenue Up

Another goal is to generate huge revenues—but not necessarily huge profits. In other words, you’ll be making and spending lots of money. This strategy can help you establish dominance in the market. It can also enable economy of scale, which will help you lower your costs down the line.

Online marketplace jet.com is using this strategy. Jet has earned a $600 million to $3 billion (depending on whom you ask) valuation by offering lower prices than Amazon. Despite the valuation, it’s not making any money yet—the Wall Street Journal picked out 12 items on Jet (selling for a total of $275.55), researched how much it cost Jet to buy and sell those items, and found that Jet was actually losing $242.91.

Get Customers

Acquiring as many customers as possible is yet another goal. Uber is the poster company for this technique; it frequently gave away rides (thus operating at a loss) because it knew that once people rode in an Uber, they were very likely to become repeat customers.

If, like Uber, your product is “sticky,” or if it’s available as freemium, than getting customers should be your primary objective.

Develop a Reputation

If you’re positioning your product as affordable and attainable, your prices should be on the lower side. Alternatively, if your product is a luxury good, price it high. Many people confer high prices with better quality, even if there’s no real evidence that’s the case.

Continue reading %Everything You Need to Know About Setting Your Prices%


by Aja Frost via SitePoint