The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Include javascript in mcml

Last post 09-22-2006, 12:27 AM by j_souhail. 4 replies.
Sort Posts: Previous Next
  •  09-21-2006, 1:24 AM 543

    Include javascript in mcml

    how should i include a javascript function inside my mcml code?

    i have a .js file which contains some functions... the file is called "ResolutionDetector.js"

    it contains a function called "GetResolution"

    how should i include it in my mcml code... in order to call the function.

    i included the file in my solution in the resources folder

     

    Tank You,

    Souhail J. Jabbour


    Souhail J. Jabbour (Activemania)
  •  09-21-2006, 6:58 AM 546 in reply to 543

    Re: Include javascript in mcml

    Short answer - unlike HTML, you can't directly embed (or reference) javascript in your markup.

    MCML can only invoke code written for the .NET platform. If you have code that you need to run, it needs to be compiled into a .NET assembly.  Once you have that, there are several examples in the SDK demonstrating how to invoke code methods from markup.


    Scott Moore (Microsoft)
  •  09-21-2006, 7:42 AM 548 in reply to 546

    Re: Include javascript in mcml

    Hi and sorry for disturbing,

    what i want here is to get the screen size in any possible way to check if the TV is HDTV or a normal TV... so if you can help me out on this one i would really appreciate it.

    i have the the jscript class but i don't know how to convert it to C# in order to include it in my application... i'll post the class below. and if there is any other way to get the screen height and width using c#, it would be really helpfull.

    var ASResolution;//ASResolutionObject instance

    //ASResolutionObject class
    function ASResolutionObject()
    {
     var ScreenWidth;
     var ScreenHeight;
     var IsHDResolution;
    }

    //Neccessary to initialize ASResolution Object
    function initASResolution()
    {
     ASResolution = new ASResolutionObject();
     
     ASResolution.ScreenWidth = document.body.clientWidth;
     ASResolution.ScreenHeight = document.body.clientHeight;
     
     ASResolution.IsHDResolution = isHDResolution();
    }

    //Returns TRUE if screen-resolution is HD. Returns FALSE otherwise.
    function isHDResolution()
    {
     
     var stDefResolutions;

     //get current screen width and height
     var scrWidth =  screen.width; //document.body.clientWidth;
     var scrHeight =  screen.height; //document.body.clientHeight;
     var scrRatio = scrWidth / scrHeight ;

     var hdRatioMax = 1.78
     var hdRationMin = 1.65

     //checking width
     if( (scrRatio >=hdRationMin  )  && (scrRatio <= hdRatioMax ))
     {
       return true;

     }
     return false;
    }

    Thank You,

    Souhail J. Jabbour


    Souhail J. Jabbour (Activemania)
  •  09-21-2006, 8:45 AM 550 in reply to 543

    Re: Include javascript in mcml

    That .js snippet looks like it considers "HD" to mean "widescreen" (it's checking for W/H ratios). If that's the case, then, you can use Environment.IsWidescreen (check the SDK docs for the "Environment" tag).


    Mark Finocchio (Microsoft)
  •  09-22-2006, 12:27 AM 554 in reply to 550

    Re: Include javascript in mcml

    hi,

    thanks this was really helpfull, it worked out fine for me.

    Sincerely,

    Souhail J. Jabbour


    Souhail J. Jabbour (Activemania)
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems