2015-02-24 100 views
1

当摄像头捕获视频时,是否有方法通过broadcast接收器(或任何其他方式)进行检测。BroadCast Reciever检测视频是从摄像头捕获的

我一直在使用下面的代码做了同样的相机照片:

在清单:

<receiver 
      android:name=".CameraPhotoReceiver" 
      android:enabled="true" > 
      <intent-filter> 
       <action android:name="com.android.camera.NEW_PICTURE" /> 
       <action android:name="android.hardware.action.NEW_PICTURE" /> 

       <data android:mimeType="image/*" /> 
      </intent-filter> 
     </receiver> 

广播接收器类:

public class CameraPhotoReceiver extends BroadcastReceiver { 

@Override 
public void onReceive(Context context, Intent arg1) 
{ 
    // TODO Auto-generated method stub 

    Cursor cursor = context.getContentResolver().query(arg1.getData(), null, null, null, null); 

    cursor.moveToFirst(); 

    String image_path = cursor.getString(cursor.getColumnIndex("_data")); 

    Toast.makeText(context, "New Photo is Saved as : " + image_path, Toast.LENGTH_SHORT).show(); 
} 

} 
  • 我想要陪伴plish是在从摄像头捕获新视频时从广播接收器onReceive上传视频。

  • 等待从您的经验中学习。在此先感谢

  • 编辑:具体来说,我要做到这一点只有从相机捕获的视频

+0

:刚刚尝试对清单中的相机按钮CLIK事件和检查广播接收器类的输出,该输出图像或video..if它是视频,然后执行上传到服务器的动作。 – 2015-02-24 12:06:04

+0

@BornToWin plz一行或两行代码可以解决我的问题 – 2015-02-24 12:09:46

+0

:我不明白你在说什么? – 2015-02-24 12:12:33

回答

0

也许你可以使用媒体的URI ContentObserver作为触发,然后检查的时间戳媒体商店中最新的视频文件?

+0

感谢您的回复,你能告诉我任何一个例子,我怎么才能实现这个..或一些代码 – 2015-02-24 11:38:23

0

你有这样的清单声明:

<receiver 
     android:name=".CameraEventReciver" 
     android:enabled="true" > 
     <intent-filter> 
      <action android:name="android.hardware.action.NEW_PICTURE" /> 
      <action android:name="android.hardware.action.NEW_VIDEO" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:mimeType="image/*" /> 
      <data android:mimeType="video/*" /> 
     </intent-filter> 
    </receiver>