2011-10-18 64 views
2

我是一種新手webOS開發人員,我目前正在開發一個應用程序,其中我需要爲某個用戶拍攝 的照片。如何使用Enyo(webOS)中的MediaCapture拍照?

我一直在尋找 互聯網上的許多資源和網站,但我找不到解決我的問題。

我跟這裏列出的指示:

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"} 
     ); 
}, 

當我運行在惠普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 [email protected]@@@@@, /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於是我跟着說說「屬性包」的指示,我明白,這是你聲明的屬性,但是我不我不知道 如何獲取我需要加載MediaCaptureObject的設備密鑰。

當按下按鈕,我得到:

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

我希望你CAL幫助我。 這個應用程序非常重要。

謝謝。

回答

0

你看過3.0.4 SDK中的示例嗎?

它附帶可拍照的MediaCapture示例應用程序。獲取deviceUri的方法與您所做的完全不同,initialize方法獲取格式列表作爲參數。

+0

是的,實際上發佈是3天或4天前。在webOS 3.0.2相機不可用。我會盡早編輯我的問題。謝謝。 – vicsonic