2016-04-13 17 views
0

ビデオ録画はIOSで正常に動作し、Androidはデータをキャッチできません。ビデオの意図はアンドロイド(Appcelerator)で使用することはできません

問題ではなく)win.getActivityを(使用するためにいくつかのアドバイスがあった

var curActivity = Ti.Android.currentActivity; 
curActivity.startActivityForResult(intent, function(e) { .... 

のようですが、私は使用することができます何の変数を持っていません。 $ .cameraWin this が機能していません。 アドバイスはありますか?

INDEX.XML

<Alloy> 
 
    <TabGroup>   
 
    <Tab id="websiteTab" title="Web"> 
 
      <Require backgroundColor="black" color="white" id="webTab" src="website" type="view"/> 
 
     </Tab> 
 
     <Tab id="cameraTab" title="Camera"> 
 
      <Require backgroundColor="black" color="white" id="cameraTab" src="camera" type="view"/> 
 
     </Tab> 
 
     <Tab backgroundColor="black" color="white" id="loginTab" title="Login"> 
 
      <Require backgroundColor="black" color="white" id="loginTab" src="login" type="view"/> 
 
     </Tab> 
 
     <Tab backgroundColor="black" color="white" id="registerTab" title="Map"> 
 
      <Require backgroundColor="black" color="white" id="registerTab" src="register" type="view"/> 
 
     </Tab> 
 
    </TabGroup> 
 
</Alloy>

camera.xml

<Alloy> 
 
    <Window id="cameraWin"> 
 
     <Label id="Label_1" text="Gib Deinem Video einen Namen"/> 
 
     <TextField id="TextField_1"/> 
 
     <Button id="Button_1" onClick="doClick" title="Aufnehmen und hochladen"/> 
 
     <ProgressBar id="ProgressBar_1"/> 
 
     <Picker id="Picker_1" selectionIndicator="true" useSpinner="true"> 
 
      <PickerColumn id="PickerColumn_1" title="Kategorie"> 
 
       <Row title="Fußball"/> 
 
       <Row title="Handball"/> 
 
       <Row title="Schifahren"/> 
 
       <Row title="Einkehren"/> 
 
      </PickerColumn> 
 
     </Picker> 
 
     <Label id="Label_2" text="Veranstaltung/Kategorie"/> 
 
    </Window> 
 
</Alloy>

camera.js

function doClick(e) { 
 
    Ti.API.info(Titanium.Platform.osname); 
 
    if (Titanium.Platform.osname == 'iphone') { 
 
    //record for iphone 
 
    $.ProgressBar_1.value = 0; 
 
    $.ProgressBar_1.message = "Hochladen" 
 
    Titanium.Media.showCamera({ 
 
     success: function(event) { 
 
     var video = event.media; 
 
     movieFile = Titanium.Filesystem.getFile(
 
      Titanium.Filesystem.applicationDataDirectory, 
 
      'mymovie.mov'); 
 

 
     movieFile.write(video); 
 
     videoFile = movieFile.nativePath; 
 
     var xhr = Titanium.Network.createHTTPClient(); 
 
     xhr.onload = function(e) { 
 
      Ti.UI.createAlertDialog({ 
 
      title: 'Success', 
 
      message: 'status code ' + this.status 
 
      }).show(); 
 
      Ti.API.info(this.responseText); 
 
     }; 
 
     xhr.open('POST', 'XXXXXXXXXX'); 
 
     xhr.send({ 
 
      Filedata: event.media, 
 
      /* event.media holds blob from gallery */ 
 
      title: $.TextField_1.value, 
 
      catid: 17 
 
     }); 
 
     // onsendstream called repeatedly, use the progress property to 
 
     // update the progress bar 
 
     xhr.onsendstream = function(e) { 
 
      $.ProgressBar_1.value = e.progress * 100; 
 
      $.ProgressBar_1.message = "Hochladen von Video"; 
 
      Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress * 100); 
 

 
     }; 
 

 

 
     }, 
 
     cancel: function() {}, 
 
     error: function(error) { 
 
     // create alert 
 
     var a = 
 
      Titanium.UI.createAlertDialog({ 
 
      title: 'Video' 
 
      }); 
 

 
     // set message 
 
     if (error.code == Titanium.Media.NO_VIDEO) { 
 
      a.setMessage('Device does not have video recording 
 
          capabilities '); 
 
     } else { 
 
      a.setMessage('Unexpected error: ' + error.code); 
 
     } 
 

 
     // show alert 
 
     a.show(); 
 
     }, 
 
     mediaTypes: Titanium.Media.MEDIA_TYPE_VIDEO, 
 
     videoMaximumDuration: 120000, 
 
     videoQuality: Titanium.Media.QUALITY_MEDIUM 
 
    }); 
 
    } else { 
 

 
    var intent = Titanium.Android.createIntent({ 
 
     action: 'android.media.action.VIDEO_CAPTURE' 
 
    }); 
 
    Ti.API.info('Intent created. ..'); 
 
    var curActivity = Ti.Android.currentActivity; 
 
    curActivity.startActivityForResult(intent, function(e) { 
 
     if (e.error) { 
 
     Ti.UI.createNotification({ 
 
      duration: Ti.UI.NOTIFICATION_DURATION_LONG, 
 
      message: 'Error: ' + e.error 
 
     }).show(); 
 
     } else { 
 
     Ti.API.info('Drinnen'); 
 
     Ti.Api.info(e.resultCode); 
 
     if (e.resultCode === Titanium.Android.RESULT_OK) { 
 
      Ti.API.info('Drinnen'); 
 
      videoFile = e.intent.data; 
 
      var source = Ti.Filesystem.getFile(videoFile); 
 
      var movieFile = 
 
      Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'mymovie.3gp'); 
 
      Ti.API.info('Sichert'); 
 
      source.copy(movieFile.nativePath); 
 
      Titanium.Media.saveToPhotoGallery(movieFile); 
 
      var xhr = Titanium.Network.createHTTPClient(); 
 
      xhr.onload = function(e) { 
 
      Ti.UI.createAlertDialog({ 
 
       title: 'Success', 
 
       message: 'status code ' + this.status 
 
      }).show(); 
 
      Ti.API.info(this.responseText); 
 
      }; 
 
      var fileContent = movieFile.read(); 
 
      Ti.API.info('Video rauf'); 
 
      xhr.open('POST', 'XXXXXXXXXXX' 
 
      Filedata: fileContent, 
 
      /* event.media holds blob from gallery */ 
 

 
      title: $.TextField_1.value, 
 
      catid: 17 
 
      }); 
 
      // onsendstream called repeatedly, use the progress property to 
 
      // update the progress bar 
 
      xhr.onsendstream = function(e) { 
 
      $.ProgressBar_1.value = e.progress * 100; 
 
      $.ProgressBar_1.message = "Hochladen von Video"; 
 
      Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress * 100); 
 

 
      }; 
 
     } else { 
 
      Ti.UI.createNotification({ 
 
      duration: Ti.UI.NOTIFICATION_DURATION_LONG, 
 
      message: 'Canceled/Error? Result code: ' + 
 
       e.resultCode 
 
      }).show(); 
 
     } 
 
     } 
 
    }); 
 

 
    } 
 
};

答えて

1

代替方法:それはすでに働いている https://github.com/appcelerator/titanium_mobile/pull/7929

(サムスンギャラクシー:私は現在、通常のSDKにはAndroidにビデオ録画を得ることに取り組んでいる

S6には問題を抱えています。私は修正する必要があります。適切なプレビューサイズを持つように電話機を回転させる必要がありますが)さらにテストが必要です。これでiOSと同じようにバック/フロントカメラを使ってビデオを録画することができます。

しかし、GAバージョンにはまだまだ時間が必要です。すぐに必要な場合は、自分でsdkをコンパイルすることができます(私はLinuxビルドを提供することができます)。

0

私は似たようなプロジェクトを持っていますが、私はビデオではなく静止画を撮っていますが、すべての目的と目的で同じように動作する必要があります。私のコードで

私が持っている:

var curActivity = $.cameraWin.activity; 
:あなたは、おそらくこのようcurActivityを設定しますあなたの例パー

win.activity.startActivityForResult(... 

:これは私を可能に

var win = $.camera_view; 

以降での私の活動を開始します

[編集]

あなたはまだあなたがビデオを保存する場所を指定する.putExtraUriを使用して試すことができます何の結果を取得しない場合:

var tempfile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, "tempvideo.mpg"); 
intent.putExtraUri("output",tempfile.nativePath); 

あなたはstartActivityForResultを呼び出す前に、これを設定しますが。

関連する問題