- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图允许用户在 react-native 应用程序中上传视频,但我什至无法访问相机。
** 不使用世博会。我使用 react-native cli 并使用 react-native-init 生成我的项目**
** 使用 react-native 版本 0.53.0。安卓版本 5.1 **
** 更新:经过一些好的建议后,我将我的 android/app/build.gradle 文件中的 compileSdkVersions 和 targetSdkVersions 更改为 > 23,并且知道问题不在于我的权限。此外,已弃用的 RCTCamera 版本的 react-native-camera 工作正常,我能够捕获静止图像和视频并将它们保存到设备中。只有使用 RNCamera 的主版本在每次屏幕加载时仍然会使应用程序崩溃:/
这不太理想,因为我不想在我的应用程序中有弃用的代码。所以当我在下面提到 react-native-camera 时,我指的是使用 RNCamera 而不是 RCTCamera 的当前版本。 **
我尝试使用 react-native-camera 包( https://github.com/react-native-community/react-native-camera ),但这会导致我的应用程序每次都崩溃。另外我想使用用户已经安装的相机应用程序,而不是构建我自己的相机 View ,这是 react-native-camera 需要的。
环顾四周,我偶然发现了三种有希望的方法来解决这个问题:
1) 链接 - 据我从 StackOverflow 帖子 (React native send a message to specific whatsapp Number 2) 中了解到,链接可用于打开用户在其设备上拥有的其他应用程序。我认为这也可以用来访问相机应用程序。但我还没有找到任何有关这方面的信息。如何检查用户是否拥有相机应用程序,然后链接到他们?理想情况下,用户手机上会出现一个弹出菜单,要求用户从可用的相机应用程序列表中进行选择。
2) 这篇来自 android 开发者文档的帖子 - https://developer.android.com/training/camera/videobasics.html .这描述了如何准确地做我想做的事,但是我在制作用于我的组件的 native 模块时遇到了麻烦。我对在 react-native 中构建桥梁有非常基本的知识,并且只有在阅读了几篇列出所有代码的文章后才能使一个简单的 native Toast 模块工作。那么任何人都可以编写一个 VideoModule.java 文件来实现与 android 文档指定的相同功能吗?这对我来说似乎是最简单的解决方案,但我对 Java/android 知识的缺乏阻碍了我。
3) ReactNativeWebRTC - 我已经在应用程序的不同屏幕上成功地包含了这个模块 (https://github.com/oney/react-native-webrtc)。但是当我使用这个模块在两个对等点之间流式传输视频时,它看不到如何使用它来上传视频。我查看了是否有类似于我用于应用程序网络版本的 MediaRecorder API 的东西,但我没有任何运气。但我知道,如果我可以从媒体流中获取二进制数据,那么我可以将其直接发送到我的服务器。那么,有没有办法直接存储来自 getUserMedia() 方法的媒体流,react-native-webrtc 在缓冲区中使用的媒体流没有像 web 上的 MediaRecorder?
任何解决方案在这里都会非常有帮助。而且由于我目前只有一部 Android 手机可供测试,因此我不需要有关如何使其与 iOS 一起使用的信息。只是安卓的解决方案。非常感谢。
这是我的 AndroidManifest.xml 权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load
the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.slimnative"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':WebRTCModule')
compile project(':react-native-svg')
compile (project(':react-native-camera')) {
// exclude group: "com.google.android.gms"
exclude group: "com.android.support"
}
// compile ("com.google.android.gms:play-services-vision:10.2.0") {
// force = true;
// }
compile ('com.android.support:exifinterface:26.0.1') {
force = true;
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
}
}
最佳答案
嘿@mraaron 我刚刚制作了一个 react 原生应用程序,我必须在其中制作和上传视频,基本上你可以使用两种方法:
1) React Native Image Picker https://github.com/react-community/react-native-image-picker which opens up the native camera to record videos and in response will give u the path and other info. This module has both functionality of images and videos while defining options u can specify mediaType: 'photo', 'video', or 'mixed' on iOS, 'photo' or 'video' on Android
2) React Native Camera https://github.com/react-native-community/react-native-camera in this u can customise the camera window as it does not open the native camera app
Note:- I have implemented both the packages and both are working absolutely fine in android as well as ios, if u need any help u can ping me up.
关于android - React-native 访问设备摄像头? (特别是安卓),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48779869/
避免必须自己创建整个相机应用程序,我调用: Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); this.startActivit
我使用这种方法从前置摄像头录制视频: Recording video via Mediarecorder 它在我的 Nexus 4 上运行良好,但有人说有很多手机的前置摄像头无法录制视频,只能拍照。我
我正在使用 Android 手机的摄像头作为输入来测试成像算法,并且需要一种方法来始终如一地测试算法。理想情况下,我想获取预先录制的视频源并让手机“假装”视频源是来自相机的实时视频。 我理想的解决方案
我想在 android 上通过 v4l 访问外部 USB 摄像头。 我试过了 SimpleWebCam .在对原始源代码进行一些细微修改后,我实现了使其在 Root过的 android 设备上运行。然
我正在尝试连接两个连接到单个 USB 端口的 USB 网络摄像头。问题是当时只有一个摄像头工作...我在 python 中使用 OpenCV。这可能吗?我的目标是将多台相机连接到一台计算机以进行机器视
我想知道如何在 virtualbox 中使用笔记本电脑的内置网络摄像头和 android x86。 我已经尝试启动默认的“相机”应用程序,它告诉我必须配置 SDCard,我在本教程中所做的:SD ca
我在 64 位华硕的 Ubuntu 12.10 上安装了 ARToolKit。安装没有错误,所以我觉得我没问题。但是当我想尝试一个例子时,它找不到相机。如果我在 char *vconf = ""; 没
我想以编程方式移动 webvr 场景中 View 的位置。为此,我使用了position.add 方法。 以下是我如何以编程方式移动相机: 摄像机移至此处: var obj3d = docume
我正在使用 Camera 2 API 将 JPEG 图像保存在磁盘上。我的 Nexus 5X 目前有 3-4 fps,我想将其提高到 20-30。可能吗? 将图像格式更改为 YUV 我设法生成 30
Baby Monitor (http://www.babymonitor3g.com/) 等应用程序可让两台 iOS 设备相互连接。连接后,一台设备可以激活另一台设备上的摄像头、灯光和麦克风,即使该应
我有一个论坛帖子表单,允许发帖人附加录音和/或网络摄像头快照。这两个都是使用 navigator.getUserMedia() 实现的应用程序接口(interface)。对于音频,我建立了 varia
我对 Opencv 和 Python 有疑问。当我尝试从相机中查看帧时,它无法识别 USB 相机,我使用了带有两个 USB 相机的书籍中的标准代码,问题是只有一个相机工作,我不知道。我在 window
我编写了一个程序,基本上使用步进电机 + a4988 驱动程序将托盘放在连接到 Raspberry Pi 的相机下方。代码将托盘带到起始位置,迈出一步,拍照并重复 10 次。然后托盘返回到起始位置。我
我的 uEye 相机遇到了一个问题。使用我的笔记本电脑摄像头(id 0)或 usb 上的网络摄像头(id 1)这条线完美运行: TheVideoCapturer.open(1); (TheVideoC
我是 Android 版 openCV 的新手,我需要一个在后台运行的图像处理应用(检测图像的线条)。 我已经制作了一个应用程序来完成我需要的所有图像处理(使用 jni),但它不能在后台运行并且它使用
我正在尝试使用 OpenCV 从 USB 摄像头捕获视频。 #include #include using namespace std; using namespace cv; int main(
我正在寻找启用和禁用默认 iPhone 相机的方法,例如在特定时间或纬度/经度。有些地方是禁止摄像头的,所以我们可以在到达这样的地方时关闭它,这里只是举个例子。好吧,我认为在 iPhone 中禁用和启
有人有这种“东西”的工作样本吗? 在理论上,以这种方式实现它是个好主意,但我没有看到任何相关的代码 fragment 来说明如何实现它。 我不要花哨的东西,越简单越好。我只想在单独的线程上实现与相机控
我正在开发一个新网站。您可以加入房间通话并进行语音通话,因此可以使用您的网络摄像头,但您也可以共享您的屏幕。 问题是当我将轨道添加到流中时,对等点不再工作......我不知道如何解决这个问题。我还尝试
我需要在 Flutter 中创建一个考试应用程序,我们需要每隔一段时间拍摄用户的照片和视频,而在执行此操作时我们不想显示相机屏幕。 我尝试使用 Flutter 的 Camera 插件,但我无法找到任何
我是一名优秀的程序员,十分优秀!