2013-11-01 84 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录像机应用程序的开始和结束时间之间,我知道这是录制的视频。

相关问题