Answered by:
Navigation Page not Render on Metro Java Script App

Question
-
Hi all,
I am new to JavaScript/HTML5.
I am trying to make a program based on video on BUILD "776-HD Metro style app Video and Audio Part 2.wmv". I have been tried five times from scratch and compare character by character with the video, but I am still not having the Video on my local machine and also on my metro simulator, I only have the application title like the regular navigation app template. I've checked the project appxmanifest to allow access to my Video Library.
Here my homePage.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Home Page</title> <!-- WinJS references --> <link href="//Microsoft.WinJS.0.6/css/ui-dark.css" rel="stylesheet"> <script src="//Microsoft.WinJS.0.6/js/base.js"></script> <script src="//Microsoft.WinJS.0.6/js/ui.js"></script> <link href="/css/default.css" rel="stylesheet"> <link href="/css/homePage.css" rel="stylesheet"> <script src="/js/homePage.js"></script> <style> /* Overall list dimensions */ .mediumTemplatizedListView { width: 90%; height: 90%; } /*image*/ .mediumTemplatizedListView img { width: 100%; } .win-listview-mediumImageTemplate { width: 250px; height: 200px; overflow: hidden; margin-right: 6px; margin-bottom: 5px; } </style> </head> <body> <!-- The content that will be loaded and displayed. --> <div class="fragment homepage"> <header aria-label="Header content" role="banner"> <button class="win-backbutton" aria-label="Back" disabled></button> <h1 class="titlearea win-type-ellipsis"><span class="pagetitle">Welcome to Build776 Video Demo!</span></h1> </header> <section aria-label="Main content" role="main"> <div id="listViewDiv" class="mediumTemplatizedListView"></div> </section> </div> </body> </html>
Here my homePage.js:
(function () { "use strict"; // This function is called whenever a user navigates to this page. It // populates the page elements with the app's data. function ready(element, options) { initialize(); } WinJS.UI.Pages.define("/html/homePage.html", { ready: ready }); /* this is me */ function initialize() { // Create a StorageFileQuery representing the Picture Library var library = Windows.Storage.KnownFolders.videosLibrary; var queryOptions = new Windows.Storage.Search.QueryOptions; queryOptions.folderDepth = Windows.Storage.Search.FolderDepth.deep; queryOptions.indexerOption = Windows.Storage.Search.IndexerOption.useIndexerWhenAvailable; queryOptions.fileTypeFilter.append(".mp4"); queryOptions.fileTypeFilter.append(".wmv"); var fileQuery = library.createFileQueryWithOptions(queryOptions); // Specify options for the Storage DataSource Adaptor var dataSourceOptions = { mode: Windows.Storage.FileProperties.ThumbnailMode.videosView, requestedThumbnailSize: 200 }; var dataSource = new WinJS.UI.StorageDataSource(fileQuery, dataSourceOptions); // Specify options for the ListView control var listViewOptions = { dataSource: dataSource, itemRenderer: storageRenderer, layout: new WinJS.UI.GridLayout(), selectionMode: "none" }; var listViewControl = new WinJS.UI.ListView(document.getElementById("listViewDiv"), listViewOptions); } function storageRenderer(item) { var thumb = item.data.thumbnail; var result = document.createElement("div"); result.className = "win-listview-mediumImageTemplate"; if (thumb) { var url = URL.createObjectURL(thumb, true); result.innerHTML = "<img src='" + url + "'/>"; } else { result.innerHTML = "<div></div>"; } var text = document.createElement("div"); text.innerText = item.data.fileName; result.appendChild(text); return result; }; /* this is me */ })();
Please help me.
Jannen Siahaan - Indonesia
Thursday, May 10, 2012 5:09 AM
Answers
-
Hi Jannen,
The structure and state of programming has changed from the time of the //Build/ conference to the Consumer preview. There is a sticky post that has a link on how to migrate //Build/ code to Consumer preview and I suggest you read that first. "Migrating Windows 8 Developer Preview code to Consumer Preview"
After reading that and make any necessary changes, I would suggest you debug the code and try and detect what could be failing. Use the F9 key to place a breakpoint at the top of each function and inside any promises you have and ensure the code is taking the path you think it should!
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Thursday, May 10, 2012 7:30 PM
- Marked as answer by humaNiT Friday, May 11, 2012 1:03 PM
Thursday, May 10, 2012 7:30 PMModerator -
Hi Jannen,
Start with a Blank JavaScript app. Notice in Default.html it does the following:
"use strict"; var app = WinJS.Application; app.onactivated = function (eventObject) { if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { if (eventObject.detail.previousExecutionState !== Windows.ApplicationModel.Activation.ApplicationExecutionState.terminated) { // TODO: This application has been newly launched. Initialize // your application here. } else { // TODO: This application has been reactivated from suspension. // Restore application state here. } WinJS.UI.processAll(); } }; app.oncheckpoint = function (eventObject) { // TODO: This application is about to be suspended. Save any state // that needs to persist across suspensions here. You might use the // WinJS.Application.sessionState object, which is automatically // saved and restored across suspension. If you need to complete an // asynchronous operation before your application is suspended, call // eventObject.setPromise(). }; app.start();
After WinJS.UI.processAll(); you should call your initialize function.
-Jeff
Jeff Sanders (MSFT)
- Edited by Jeff SandersMicrosoft employee, Moderator Friday, May 11, 2012 12:43 PM
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Friday, May 11, 2012 12:43 PM
- Marked as answer by humaNiT Friday, May 11, 2012 1:02 PM
Friday, May 11, 2012 12:43 PMModerator
All replies
-
Hi Jannen,
The structure and state of programming has changed from the time of the //Build/ conference to the Consumer preview. There is a sticky post that has a link on how to migrate //Build/ code to Consumer preview and I suggest you read that first. "Migrating Windows 8 Developer Preview code to Consumer Preview"
After reading that and make any necessary changes, I would suggest you debug the code and try and detect what could be failing. Use the F9 key to place a breakpoint at the top of each function and inside any promises you have and ensure the code is taking the path you think it should!
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Thursday, May 10, 2012 7:30 PM
- Marked as answer by humaNiT Friday, May 11, 2012 1:03 PM
Thursday, May 10, 2012 7:30 PMModerator -
Thank you Jeff,
Sorry that my question is too wide. Actually the problem is at the beginning. It should call "function initialize" at the first time when "homePage.html" is ready, but it is not working. I found the post, "Migrating Windows 8 Developer Preview code to Consumer Preview". I found that we need to change CSS and JavaScript referenes, this has been done the first time I create the project and I did not chenge this. I'll try to read more and try find the solution again in there. But please take a look back how to make the "initialize" function. I have try other navigation template, and the ready function worked fine. I do help to demonstrate a metro app to my audiens.
Thank you so much
Jannen
Jannen Siahaan - Indonesia
Thursday, May 10, 2012 10:32 PM -
Hi Jannen,
Start with a Blank JavaScript app. Notice in Default.html it does the following:
"use strict"; var app = WinJS.Application; app.onactivated = function (eventObject) { if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { if (eventObject.detail.previousExecutionState !== Windows.ApplicationModel.Activation.ApplicationExecutionState.terminated) { // TODO: This application has been newly launched. Initialize // your application here. } else { // TODO: This application has been reactivated from suspension. // Restore application state here. } WinJS.UI.processAll(); } }; app.oncheckpoint = function (eventObject) { // TODO: This application is about to be suspended. Save any state // that needs to persist across suspensions here. You might use the // WinJS.Application.sessionState object, which is automatically // saved and restored across suspension. If you need to complete an // asynchronous operation before your application is suspended, call // eventObject.setPromise(). }; app.start();
After WinJS.UI.processAll(); you should call your initialize function.
-Jeff
Jeff Sanders (MSFT)
- Edited by Jeff SandersMicrosoft employee, Moderator Friday, May 11, 2012 12:43 PM
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Friday, May 11, 2012 12:43 PM
- Marked as answer by humaNiT Friday, May 11, 2012 1:02 PM
Friday, May 11, 2012 12:43 PMModerator -
Thanks Jeff,
It's ok now after I make some changes base on the post, "Migrating Windows 8 Developer Preview code to Consumer Preview". Now I have other problem and I am trying to solve my self for my benefit, and I may make a new thread on my new other problem, on this case.
Again thanks a lot
Jannen Siahaan - Indonesia
Friday, May 11, 2012 1:05 PM -
Great Jannen!
Definately create a post for your new questions if you cannot solve them!
-Jeff
Jeff Sanders (MSFT)
Friday, May 11, 2012 1:08 PMModerator