locked
JavaScript runtime error: 'args' is undefined. RRS feed

  • Question

  • Hi I am creating  a  Javascript video player to play a local video file  for windows 8   app.  I can't run the app. it shows me a error as like this

    0x800a1391 - JavaScript runtime error: 'args' is undefined..

    Here is  my  code..for default.html

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>Html5 video</title>
        <meta name="tags" content="" />
        <meta name="keywords" content="html5 html video"/>
        <meta name="description" content="HTML5 video tag demo." />
        <meta name="author" content="SARAVANA" />
    
        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
    
        <!-- video references -->
        <link href="/css/default.css" rel="stylesheet" />
        <script src="/js/default.js"></script>
    </head>
    <body>
        <div class="html5video fragment">
            <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">HTML5 Video</span>
                </h1>
            </header>
            <section aria-label="Main content" role="main">
                          <video id=player" controls="controls">
                              <!--<source  src="hprichv.mp4" type="video/mp4" />-->
                              <source  src="hprichv.mp4" type="video/mp4" />
                          </video>
                            <button id="pickFile">Pick File</button>
            </section>
        </div>
    
    </body>
    </html>
    

    js code default.js

    (function () {
        "use strict";
    
        args.setPromise(WinJS.UI.processAll().done(function (e) {
            pickFile.addEventListener("click", function (e) {
                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.fileTypeFilter.push(".mp4", ".webm", ".ogv");
                picker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.videosLibrary;
                picker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
                picker.pickSingleFileAsync().then(function (file) {
                    if (file) {
                        var src = URL.createObjectURL(file);
                        payer.setAttribute("src", src);
                        player.load();
                        player.play();
                    }
                }, function (err) {
                    console.log(err.description);
                });
            }, false);
        }));
    
    })();
    

    Experts any one help me

    Friday, July 12, 2013 10:34 AM

All replies

  • Hello,

    As I inspected your javascript code snippet I saw that you are removing the app.onactivated event handler and placing args.setPromise() behind "use strict" directly.  it should include in  app.onactivated event handler as follows:

    (function () {
        "use strict";
    
        WinJS.Binding.optimizeBindingReferences = true;
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
    
        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== 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.
                }
                args.setPromise(WinJS.UI.processAll());
            }
        };
    
        app.oncheckpoint = function (args) {
            // 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
            // args.setPromise().
        };
    
        app.start();
    })();

     The video player function will work if you place setPromise() properly. Thanks.

    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Monday, July 15, 2013 6:40 AM
    Moderator
  • Thank you Wang
    Tuesday, July 16, 2013 6:02 AM
  • HI Wang, Now I am developing another html 5 video application in which I want to present four videos which should be represented in four image icons in the first app page I want to relate each icon to each video.. when I press any icon the video corresponding to that video should be played.. But I want to responsiveness in touching  of icons.. please provide me a correct idea or source please  Mr. Wang..

    Thank You

    Tuesday, July 16, 2013 7:42 AM
  • Hi NPSARAVANAKUMAR,

    Thanks for your reply.

    As far as I understand, you can tigger video to play when you click on corresponding icon.

    First, you can hide the video and preset video's src. once the icon click, you can display it, and use id("videoID").play() to call the video to play.

    The following article introduces how to use play to in apps. you can refer:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh465184.aspx

    Hope this helps, thanks.


    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 16, 2013 9:37 AM
    Moderator
  • Hi Wang

    I created the app succesfully..

    I made the app to play each video in new page..Now I  want to place the advertisement in each page of app but When I place it works in first page of the app only ... I give here a code of a

    <!DOCTYPE html>
    <html>
        <head>
            <title>train</title>
      <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
    
            <link href="css/train.css" rel="stylesheet" />
    
            <script src="/MSAdvertisingJS/ads/ad.js"></script>
    
        </head>
        <body>
           <div class="train fragment">
               
              <a href="link1.html" class ="image-link"><img src ="media/Home.png" style="width: 39px; height: 33px;"/></a>
            
            <section aria-label="Main content" role="main">
                    <video autoplay loop style="width: 1350px; height: 784px;">
                        <source src="media/3.mp4" type="video/mp4" />
                    </video>
             </section>   
          </div>
    
       <div id="myAd" style="; top: 21px; left: 30.07px; width: 1281.43px; height: 78.72px; z-index: 1;" 
       data-win-control="MicrosoftNSJS.Advertising.AdControl" 
       data-win-options="{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab', adUnitId: '10043105'}">
       </div>
    
    
        </body>
    </html>

    one page where the video plays.. Please do the help



    Wednesday, July 17, 2013 9:33 AM