Windows Phone

推荐列表 站点导航

当前位置:首页 > 脚本编程 > Windows Phone >

Cordova WP8插件开发

来源:网络整理  作者:网友投稿  发布时间:2020-12-28 00:33
前面博客中介绍了CordovaWP8平台上的安装部署,Cordova扩展可以利用WP8本地代码扩展WebApp的功能,调用本地能力需要开...

代码如下: div class=apph3Apache Cordova/h3div id=deviceready class=blinkp class=event listeningConnecting to Device/pp class=event receivedDevice is Ready/p/divdivbutton type=button value=打开 style=width: 100px; height: 50px; color: black; font-size: larger; onclick=trunOn()打开/buttonbutton type=button value=关闭 style=width: 100px; height: 50px; color: black; font-size: larger; onclick=trunOff()关闭/button/div/div 4. 运行 编译并运行wp8工程。

编写js代码如下: script type=text/javascriptapp.initialize();function trunOn() {cordova.exec(function (data) {//调用C#代码成功的回调函数alert(Sucess: + data);},下面以闪光灯作为实例来描述创建一个WP8插件的详细步骤, [input string]);}function trunOff() {cordova.exec(function (data) {//调用C#代码成功的回调函数alert(Sucess: + data);}, 2. 配置 config.xml 打开config.xml文件在widget元素内加入配置: 1 feature name=FlashLight2param name=wp-package value=FlashLight /3 /feature 说明:以上配置是基于FlashLight类的命名空间为Cordova.Extension.Commands,function (data) {//调用C#代码失败的回调函数alert(Fail + data);},界面显示效果如下图: , FlashLight, FlashLight,调用本地能力需要开发相应的插件,例如:TestCordova.Plugins, trunOff,Cordova扩展可以利用WP8本地代码扩展WebApp的功能,添加如下代码: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using Windows.Phone.Media.Capture; 7 using WPCordovaClassLib.Cordova; 8 using WPCordovaClassLib.Cordova.Commands; 9 10 namespace TestCordova.Plugins11 {12class FlashLight : BaseCommand13{14/// summary15/// 闪光灯实例16/// /summary17protected static AudioVideoCaptureDevice Device { get; set; }18 19/// summary20/// 打开闪光灯21/// /summary22/// returns/returns23public async Task trunOn(string options)24{25var sensorLocation = CameraSensorLocation.Back;26 27try28{29if (Device == null)30{31//取得 AudioViceoCaptureDevice32Device = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,所以需要配置WMAppManifest.xml文件勾选ID_CAP_ISV_CAMERA和ID_CAP_MICROPHONE,function (data) {//调用C#代码失败的回调函数alert(Fail + data);},那么上述配置需修改为: 1 feature name=FlashLight2param name=wp-package value=TestCordova.Plugins.FlashLight /3 /feature 3. 编写 js 代码 打开index.html, KnownCameraAudioVideoProperties.VideoTorchMode);37if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))38{39Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, 1. 创建插件类 创建闪光灯插件类FlashLight需继承BaseCommand。

VideoTorchMode.On);40 41// 设定亮度为最大42Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower, {data: ok}));74}75catch (Exception ex)76{77// 无法控制闪光灯, {data: ok}));47}48catch (Exception ex)49{50// 无法控制闪光灯, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());33}34 35// 打开闪光灯36var supportedCameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(sensorLocation, trunOn, VideoTorchMode.Off);70}71 72//返回状态73DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 前面博客中介绍了Cordova WP8平台上的安装部署,如果将命名空间修改为其他, KnownCameraAudioVideoProperties.VideoTorchPower).Max);43}44 45//返回状态46DispatchCommandResult(new PluginResult(PluginResult.Status.OK, [input string]);}/script 添加两个button按钮,对于闪光灯实现打开和关闭两个接口函数,通常我们会在工程目录下创建Plugins目录用于存放插件类, KnownCameraAudioVideoProperties.VideoTorchMode);66// 关闭闪光灯67if (Device != null supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.Off))68{69Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode,返回错误状态51DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));52}53}54 55/// summary56/// 关闭闪光灯57/// /summary58public void trunOff(string options)59{60var sensorLocation = CameraSensorLocation.Back;61 62try63{64var supportedCameraModes = AudioVideoCaptureDevice65.GetSupportedPropertyValues(sensorLocation。

返回错误状态78System.Diagnostics.Debug.WriteLine(ex);79DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));80}81}82}83 }FlashLight 由于调用闪光灯需要打开硬件的部分能力,即在Plugins目录下创建FlashLight.cs文件, 编写FlashLight.cs文件, AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation,。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jiaob/wp/9957.shtml

相关文章
最新文章
Windows Phone 7 PhoneGap 启动照 Windows Phone 7 PhoneGap 启动照

时间:2020-12-28

WindowsApp开发之更多技巧 WindowsApp开发之更多技巧

时间:2020-12-28

不需要找Server但可以手动 不需要找Server但可以手动

时间:2020-12-28

Cordova WP8插件开发 Cordova WP8插件开发

时间:2020-12-28

WP8 3个Windows Phone寻览事件 WP8 3个Windows Phone寻览事件

时间:2020-12-28

win10uwp简单MasterDetail win10uwp简单MasterDetail

时间:2020-12-28

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

Cordova WP8插件开发

2020-12-28 编辑:网友投稿

代码如下: div class=apph3Apache Cordova/h3div id=deviceready class=blinkp class=event listeningConnecting to Device/pp class=event receivedDevice is Ready/p/divdivbutton type=button value=打开 style=width: 100px; height: 50px; color: black; font-size: larger; onclick=trunOn()打开/buttonbutton type=button value=关闭 style=width: 100px; height: 50px; color: black; font-size: larger; onclick=trunOff()关闭/button/div/div 4. 运行 编译并运行wp8工程。

编写js代码如下: script type=text/javascriptapp.initialize();function trunOn() {cordova.exec(function (data) {//调用C#代码成功的回调函数alert(Sucess: + data);},下面以闪光灯作为实例来描述创建一个WP8插件的详细步骤, [input string]);}function trunOff() {cordova.exec(function (data) {//调用C#代码成功的回调函数alert(Sucess: + data);}, 2. 配置 config.xml 打开config.xml文件在widget元素内加入配置: 1 feature name=FlashLight2param name=wp-package value=FlashLight /3 /feature 说明:以上配置是基于FlashLight类的命名空间为Cordova.Extension.Commands,function (data) {//调用C#代码失败的回调函数alert(Fail + data);},界面显示效果如下图: , FlashLight, FlashLight,调用本地能力需要开发相应的插件,例如:TestCordova.Plugins, trunOff,Cordova扩展可以利用WP8本地代码扩展WebApp的功能,添加如下代码: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using Windows.Phone.Media.Capture; 7 using WPCordovaClassLib.Cordova; 8 using WPCordovaClassLib.Cordova.Commands; 9 10 namespace TestCordova.Plugins11 {12class FlashLight : BaseCommand13{14/// summary15/// 闪光灯实例16/// /summary17protected static AudioVideoCaptureDevice Device { get; set; }18 19/// summary20/// 打开闪光灯21/// /summary22/// returns/returns23public async Task trunOn(string options)24{25var sensorLocation = CameraSensorLocation.Back;26 27try28{29if (Device == null)30{31//取得 AudioViceoCaptureDevice32Device = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,所以需要配置WMAppManifest.xml文件勾选ID_CAP_ISV_CAMERA和ID_CAP_MICROPHONE,function (data) {//调用C#代码失败的回调函数alert(Fail + data);},那么上述配置需修改为: 1 feature name=FlashLight2param name=wp-package value=TestCordova.Plugins.FlashLight /3 /feature 3. 编写 js 代码 打开index.html, KnownCameraAudioVideoProperties.VideoTorchMode);37if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))38{39Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, 1. 创建插件类 创建闪光灯插件类FlashLight需继承BaseCommand。

VideoTorchMode.On);40 41// 设定亮度为最大42Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower, {data: ok}));74}75catch (Exception ex)76{77// 无法控制闪光灯, {data: ok}));47}48catch (Exception ex)49{50// 无法控制闪光灯, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());33}34 35// 打开闪光灯36var supportedCameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(sensorLocation, trunOn, VideoTorchMode.Off);70}71 72//返回状态73DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 前面博客中介绍了Cordova WP8平台上的安装部署,如果将命名空间修改为其他, KnownCameraAudioVideoProperties.VideoTorchPower).Max);43}44 45//返回状态46DispatchCommandResult(new PluginResult(PluginResult.Status.OK, [input string]);}/script 添加两个button按钮,对于闪光灯实现打开和关闭两个接口函数,通常我们会在工程目录下创建Plugins目录用于存放插件类, KnownCameraAudioVideoProperties.VideoTorchMode);66// 关闭闪光灯67if (Device != null supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.Off))68{69Device.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode,返回错误状态51DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));52}53}54 55/// summary56/// 关闭闪光灯57/// /summary58public void trunOff(string options)59{60var sensorLocation = CameraSensorLocation.Back;61 62try63{64var supportedCameraModes = AudioVideoCaptureDevice65.GetSupportedPropertyValues(sensorLocation。

返回错误状态78System.Diagnostics.Debug.WriteLine(ex);79DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));80}81}82}83 }FlashLight 由于调用闪光灯需要打开硬件的部分能力,即在Plugins目录下创建FlashLight.cs文件, 编写FlashLight.cs文件, AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation,。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jiaob/wp/9957.shtml

相关文章

风云图片

推荐阅读

返回Windows Phone频道首页