23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

getPresetProfile(id("profileSelect"));<br />

// Create output file and transcode.<br />

var videoLib = Windows.Storage.KnownFolders.videosLibrary;<br />

var createFileOp = videoLib.createFileAsync(g_outputFileName,<br />

Windows.Storage.CreationCollisionOption.generateUniqueName);<br />

createFileOp.done(function (ofile) {<br />

g_outputFile = ofile;<br />

g_transcodeOp = null;<br />

var prepareOp = transcoder.prepareFileTranscodeAsync(g_inputFile, g_outputFile,<br />

g_profile);<br />

}<br />

prepareOp.done(function (result) {<br />

if (result.canTranscode) {<br />

g_transcodeOp = result.transcodeAsync();<br />

g_transcodeOp.done(transcodeComplete, transcoderErrorHandler,<br />

transcodeProgress);<br />

} else {<br />

transcodeFailure(result.failureReason);<br />

}<br />

}); // prepareOp.done<br />

id("cancel").disabled = false;<br />

}); // createFileOp.done<br />

The getPresetProfile method retrieves the appropriate profile object according to the option<br />

selected in the app. For the selections shown in Figure 10-7 (WMV and WVGA), we’d use these parts of<br />

that function:<br />

function getPresetProfile(profileSelect) {<br />

g_profile = null;<br />

var mediaProperties = Windows.Media.MediaProperties;<br />

var videoEncodingProfile;<br />

}<br />

switch (profileSelect.selectedIndex) {<br />

// other cases omitted<br />

case 2:<br />

videoEncodingProfile = mediaProperties.VideoEncodingQuality.wvga;<br />

break;<br />

}<br />

if (g_useMp4) {<br />

g_profile = mediaProperties.MediaEncodingProfile.createMp4(videoEncodingProfile);<br />

} else {<br />

g_profile = mediaProperties.MediaEncodingProfile.createWmv(videoEncodingProfile);<br />

}<br />

450

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

Saved successfully!

Ooh no, something went wrong!