gpt4 book ai didi

javascript - 如何在 Enyo (webOS) 中使用 MediaCapture 拍照?

转载 作者:行者123 更新时间:2023-11-30 06:44:53 29 4
gpt4 key购买 nike

我是一种新手 webOS 开发人员,目前我是开发一个我需要拍照的应用程序某个用户。

我一直在寻找许多资源和网站互联网,但找不到解决问题的方法。

我按照此处列出的说明进行操作:

How to take a picture using command line on webOS on HP touchpad?

我想明确表示我不想从命令行拍照。

我尝试了以下方法:

A.包含在我的 depends.js 中

"$enyo/../lib/mediacapture/"

B.在我的场景中

enyo.kind({
name: "MyComponent",
kind: "Pane",
components: [
{
kind: "enyo.MediaCapture",
name: "mediaCapture",
onInitialized: "onImageCaptureInitialized",
onError: "onImageCaptureError",
onImageCaptureComplete: "onImageCaptureComplete"
}
],
...
..
.
});

C. onCreate 函数内部

create: function () {
this.inherited(arguments);
this.$.mediaCapture.initialize(this.$.ViewPort);
},

D.在 onInitialized 事件中

onImageCaptureInitialized: function () {
var keyString;
for(var i = 0; i < this.pb.deviceKeys.length; i++) {
if(this.pb.deviceKeys[i].description.indexOf("Camera/Camcorder") >= 0) {
keyString = this.pb.deviceKeys[i].deviceUri;
break;
}
}

if(keyString) {
var formatObj = {imageCaptureFormat: this.pb[keyString].supportedImageFormats[0]};
this.$.mediaCapture.load(keyString, formatObj);
}
},

D.某按钮的onclick事件里面

takePhotoClickEvent: function (inSender) {      

this.$.mediaCapture.startImageCapture("/media/internal/CanalCocina/recipe_photo.jpg",
{
"bitrate":128000,
"samplerate":8000,
"width":480,
"height":320,
"mimetype":"image/jpeg",
"codecs":"jpeg"}
);
},

当我在 HP TouchPad 上运行该应用程序时,我会在我的控制台中看到下一条日志:

info: MediaCapture::ServiceProxy ===== MediaCapture::_initializeMediaServerInstanceSuccess() ...palm://com.palm.mediad.MediaCaptureV3_1814440/, /usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:83 [20111017-16:52:32.906482] info: MediaCapture::ServiceProxy @@@@@@----------- FIRST PROPERTY GRAB -----------@@@@@@, /usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:106 [20111017-16:52:32.913991] info: MediaCapture::ServiceProxy inResponse: {"propertyValues":[{"name":"ready","value":false},{"name":"supportedAudioFormats","value":[{"bitrate":128000,"samplerate":8000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":256000,"samplerate":16000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":705600,"samplerate":44100,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":128000,"samplerate":8000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":256000,"samplerate":16000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":705600,"samplerate":44100,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":128000,"samplerate":8000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":256000,"samplerate":16000,"width":0,"height":0,"mimetype":"audio/vnd.wave","codecs":"1"},{"bitrate":705600,"sampl

然而,当应用程序尝试加载 mediaCapture 对象时,我得到:

Uncaught TypeError: Cannot read property 'deviceKeys' of undefined, source/CCRecipesStep1View.js:186

我知道并且我明白这个错误是因为应用程序试图访问一个不存在的属性。在这个如果特定行是:

onImageCaptureInitialized: function () {
var keyString;
for(var i = 0; i < this.pb.deviceKeys.length; i++) <<------------ Here
...
..
.
}

文件 MediaCapture.js 和我遵循的说明讨论了 “Property Bag” ,我知道这是你声明属性的地方,但我不知道如何获取加载 MediaCaptureObject 所需的设备 key 。

当按下按钮时,我得到:

MediaCapture::ServiceProxy #######----------- CHANGE PROPERTIES EVENT -----------######vuData , /usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:140 [20111017-17:07:35.401836] info: MediaCapture::ServiceProxy

#----------- CHANGE PROPERTIES EVENT -----------######vuData ,

/usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:140 [20111017-17:07:35.653586] info: MediaCapture::ServiceProxy

#----------- CHANGE PROPERTIES EVENT -----------######vuData ,

/usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:140 [20111017-17:07:35.885940] info: MediaCapture::ServiceProxy

#----------- CHANGE PROPERTIES EVENT -----------######vuData ,

/usr/palm/frameworks/enyo/1.0/framework/lib/mediacapture/helper/MediaCaptureProxyHelper.js:140

然后开始无限循环:S

我希望你能帮助我。这个应用程序非常重要。

谢谢。

最佳答案

您是否看过 3.0.4 SDK 中的示例?

它附带一个用于拍照的 MediaCapture 示例应用程序。获取 deviceUri 的方法与您正在做的完全不同,初始化方法获取格式列表作为参数。

关于javascript - 如何在 Enyo (webOS) 中使用 MediaCapture 拍照?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7801330/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com