23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In Scenario 2, the sample always uses the WVGA encoding but allows you to set specific values for<br />

the video dimensions, the frame rate, the audio and video bitrates, audio channels, and audio sampling.<br />

It applies these settings in getCustomProfile (js/custom.js) simply by configuring the profile properties<br />

after the profile is created:<br />

function getCustomProfile() {<br />

if (g_useMp4) {<br />

g_profile = Windows.Media.MediaProperties.MediaEncodingProfile.createMp4(<br />

Windows.Media.MediaProperties.VideoEncodingQuality.wvga);<br />

} else {<br />

g_profile = Windows.Media.MediaProperties.MediaEncodingProfile.createWmv(<br />

Windows.Media.MediaProperties.VideoEncodingQuality.wvga);<br />

}<br />

}<br />

// Pull configuration values from the UI controls<br />

g_profile.audio.bitsPerSample = id("AudioBPS").value;<br />

g_profile.audio.channelCount = id("AudioCC").value;<br />

g_profile.audio.bitrate = id("AudioBR").value;<br />

g_profile.audio.sampleRate = id("AudioSR").value;<br />

g_profile.video.width = id("VideoW").value;<br />

g_profile.video.height = id("VideoH").value;<br />

g_profile.video.bitrate = id("VideoBR").value;<br />

g_profile.video.frameRate.numerator = id("VideoFR").value;<br />

g_profile.video.frameRate.denominator = 1;<br />

And to finish off, Scenario 3 is like Scenario 1, but it lets you set start and end times that are then<br />

saved in the transcoder’s trimStartTime and trimStopTime properties (see js/trim.js):<br />

transcoder = new Windows.Media.Transcoding.MediaTranscoder();<br />

transcoder.trimStartTime = g_start;<br />

transcoder.trimStopTime = g_stop;<br />

Through not shown in the sample, you can apply effects to a transcoding operation by using the<br />

transcoder’s addAudioEffect and addVideoEffect methods.<br />

Custom Decoders/Encoders and Scheme Handlers<br />

Clearly, there are many more audio and video formats in the world than Windows can support in-box,<br />

so an extensibility mechanism is provided in WinRT to allow for custom bytestream objects, custom<br />

media sources, and custom codecs and effects. It’s important to note again that all such extensions are<br />

available only to the app itself and are not available to other apps on the system. Furthermore, Windows<br />

will always prefer in-box components over a custom one, which means don’t bother wasting your time<br />

creating a new mp3 decoder or such since it will never actually be used.<br />

As suggested earlier with custom image formats, this subject will certainly take you into some pretty<br />

vast territory around the entire Windows Media Foundation (WMF) SDK. What’s in WinRT is really just a<br />

wrapper, so knowledge of WMF is essential and not for the faint of heart!<br />

Audio and video extensions are declared in the app manifest where you’ll need to edit the XML<br />

451

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!