2013-11-01 86 views
0

我有一個lg g-slate,具有兩個後置攝像頭以拍攝立體(3D)圖片/視頻。在我的應用程序中,我試圖調用預裝在設備上的3D視頻錄像機應用程序。我可以用下面的成功啓動應用程序:如何從其他活動返回數據,僅返回按鈕從已啓用活動返回的方式

Intent i; 
    PackageManager manager = getPackageManager(); 
    try { 
     i = manager.getLaunchIntentForPackage("com.lge.stereo.camcorder"); 
     if (i == null) 
      throw new PackageManager.NameNotFoundException(); 
     i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     startActivityForResult(i, ACTION_TAKE_VIDEO); 
    } catch (PackageManager.NameNotFoundException e) { 

記錄與應用程序的視頻後,有沒有辦法從應用程序返回除了使用後退按鈕。所以,在onActivityResult()中,結果代碼是RESULT_CANCELLED,並且我無法獲得從意圖返回的任何數據。我想獲取保存視頻的文件的Uri,但我不確定自己如何才能做到這一點,因爲使用後退按鈕是從應用程序返回的唯一方法。

我用下面的代碼之前錄製2D視頻:

Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 
startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO); 

錄製視頻後,一個對話框彈出窗口,您可以選擇「確定」按鈕返回到應用程序,並得到該文件的URI onActivityResult。

有沒有辦法啓動3D錄像機,以便我可以得到結果?

任何幫助或建議將不勝感激?謝謝

回答

0

enter image description here在您的應用程序中打開相機應用程序只有在自定義佈局。你可以在哪裏有兩個按鈕來保存和放棄視頻。當用戶按下以保存視頻時,將其保存在預定義的位置,您將會了解視頻的路徑,因爲您已經自己定義了視頻路徑,並且用戶按取消視頻時放棄位置並取消視頻或僅覆蓋後退按鈕功能。

例如,

裏面的onCreate()方法,得到相機

private Camera myCamera; 
// Get Camera for preview 
myCamera = getCameraInstance(); 


private Camera getCameraInstance() { 
     // TODO Auto-generated method stub 
     Camera c = null; 
     try { 
      // attempt to get a Camera instance 
      c = Camera.open(); 
     } catch (Exception e) { 
      // Camera is not available (in use or does not exist) 
     } 
     // returns null if camera is unavailable 
     return c; 
    } 

現在創建相機

  private MyCameraSurfaceView myCameraSurfaceView; 

     myCameraSurfaceView = new MyCameraSurfaceView(this, myCamera); 
     FrameLayout myCameraPreview = (FrameLayout) findViewById(R.id.videoview); 
     myCameraPreview.addView(myCameraSurfaceView); 

     myButton = (Button) findViewById(R.id.mybutton); 
     myButton.setOnClickListener(myButtonOnClickListener); 

     flashOff = (RadioButton) findViewById(R.id.flashoff); 
     flashTorch = (RadioButton) findViewById(R.id.flashtorch); 

表面觀和這樣

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal" > 

     <FrameLayout 
      android:id="@+id/videoview" 
      android:layout_width="720px" 
      android:layout_height="480px" /> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 

      <Button 
       android:id="@+id/mybutton" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="REC" 
       android:textSize="12dp" /> 

      <RadioGroup 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 

       <RadioButton 
        android:id="@+id/flashoff" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:checked="true" 
        android:text="OFF" 
        android:textSize="8dp" /> 

       <RadioButton 
        android:id="@+id/flashtorch" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Torch" 
        android:textSize="8dp" /> 
      </RadioGroup> 

      <Button 
       android:layout_marginTop="10dp" 
       android:id="@+id/btn_next" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="NEXT" 
       android:textSize="12dp" /> 


     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

我寧願試圖找到一種方法來使用現有的3D錄音應用程序,而不是從頭創建一個。我需要使用後置攝像頭來錄製3D視頻。現有的應用程序有幾個選項可用,例如設置3D模式(浮雕,混合或並排)以及深度控制。創建具有相同功能的應用程序將很困難。 – todd

0

好吧,我創建佈局實例找到了合適的解決方案我在調用startActivityForResult之前以毫秒爲單位獲取當前時間,然後在onActivityResult中獲取當前時間。我知道3D錄像機保存視頻的目錄,因此我遍歷目錄中的文件並檢查每個文件的最後修改時間。如果上次修改時間介於使用3D錄像機應用程序的開始和結束時間之間,我知道這是錄製的視頻。

相關問題