ControlPlugin.js exception in _getPhysicalSize on Windows 8.1

Topics: Windows 8 JavaScript
Aug 24, 2015 at 7:49 PM
Downloaded the new PF3 and tried to check out the Microsoft.PlayerFramework.Samples. At runtime, when clicking any of the actual samples, it was blowing up because DisplayInformation was undefined. I'm not sure if this is a correct work-around, but I got around this by replacing the method with the following code:
        _getPhysicalSize: function (size) {
            var scale = 1.0;
            if (Windows.Graphics.Display.DisplayInformation !== undefined) {
                scale = Windows.Graphics.Display.DisplayInformation.getForCurrentView().resolutionScale / 100;
            }
            else {
                scale = Windows.Graphics.Display.DisplayProperties.resolutionScale / 100;
            }

            if (Windows.Graphics.Display.DisplayInformation !== undefined) {
                var displayInfo = Windows.Graphics.Display.DisplayInformation.getForCurrentView();
                var w = size.width * scale / displayInfo.rawDpiX;
                var h = size.height * scale / displayInfo.rawDpiY;
                return { width: w, height: h };
            } else {
                return { width: size.width * scale, height: size.height * scale };
            }
        }
BTW I'm very happy to see active development here.
Aug 24, 2015 at 8:13 PM
Interestingly, when switching back to our client project which references PF2, a breakpoint at _getPhysicalSize shows Windows.Graphics.Display.DisplayInformation is defined. However, at that same place when running the PF3 samples app, on the same machine, it is undefined. So perhaps whatever setup populates those objects is not always occurring correctly in the PF3 samples app?