Reflection failure when attempting to access Microsoft.Phone.Media.Extended

前端 未结 3 1162
庸人自扰
庸人自扰 2020-12-02 02:25

I am developing one Flash Light application in Silverlight for windows phone 8. Currently I am deeply stuck in one issue for the use of \"Microsoft.Phone.Media.Extended\" a

相关标签:
3条回答
  • 2020-12-02 02:58

    What about getting this assembly from somewhere and adding it to your XAP directly (try asking on XDA developers)? This might work, if it's signed and not requiring any special capabilities.

    0 讨论(0)
  • 2020-12-02 02:59

    If you use the new API to "record" a video, then using the VideoTorchMode enumeration might do just want you want to create a "flashlight" effect.

    0 讨论(0)
  • 2020-12-02 03:06

    Microsoft.Phone.Media.Extended is a private API in WP7 that wasn't meant to be used by 3rd party developers. That API doesn't exist or works on WP8.

    For WP8 flashlight use the AudioVideoCaptureDevice known property of VideoTorchMode=On. Also, make sure to handle failures like exceptions or devices that don't have a Camera Torch by showing a white screen.

    Here's a code sample that turns on the camera flash on my Lumia 820 and Lumia 920:

    var sensorLocation = CameraSensorLocation.Back;
    
    try
    {
        // get the AudioViceoCaptureDevice
        var avDevice = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,
            AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());
    
        // turn flashlight on
        var supportedCameraModes = AudioVideoCaptureDevice
            .GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
        if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
        {
            avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
    
            // set flash power to maxinum
            avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower,
                AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchPower).Max);
        }
        else
        {
            ShowWhiteScreenInsteadOfCameraTorch();
        }
    
    }
    catch(Exception ex)
    {
        // Flashlight isn't supported on this device, instead show a White Screen as the flash light
        ShowWhiteScreenInsteadOfCameraTorch();
    }
    

    Make sure to add the required capabilities and requirements to your WP8 app when using the camera torch (ISV_Camera, Microphone, and ID_REQ_BACK_Camera).

    0 讨论(0)
提交回复
热议问题