我想在进行视频录制时在我的应用程序中打开手电筒模式AVCaptureTorchModeOn.
我使用下面的代码.
-(void)set_TorchMode:(BOOL)turnOn
{
AVCaptureDevice *theDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([theDevice hasTorch]) {
[theDevice lockForConfiguration: nil];
AVCaptureTorchMode currentMode = [theDevice torchMode];
BOOL isAlreadyTurnedOn = (AVCaptureTorchModeOn == currentMode);
if (isAlreadyTurnedOn != turnOn) {
[theDevice setTorchMode: turnOn? AVCaptureTorchModeOn: AVCaptureTorchModeOff];
}
[theDevice unlockForConfiguration];
}
}
Run Code Online (Sandbox Code Playgroud)
我在开始录音时打开这个方法打开,在停止录音时将其关闭.
我第一次录制它时工作正常,但是当第二次开始录制时,它开启但立即关闭.录制运行时它不会保持打开状态.
谢谢你的帮助.
我正在使用文本网格在3D对象上放置文本,但众所周知,文本网格没有任何法线...
http://docs.unity3d.com/Documentation/Components/class-TextMesh.html
...所以它没有正确点亮.我做了一个搜索,发现许多人在点亮3D文本网格时遇到了麻烦,因为它没有任何法线,但我没有找到将法线添加到文本网格对象的解决方案,所以这是我的问题.
如何为文本网格添加法线以使其正确点亮?
非常感谢您的智慧!
我有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
class="com.xamarin.recipes.filepicker.FileListFragment"
android:id="@+id/FileListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
之后我试图访问Activity中的FileListFragment:
var fileListFragment = SupportFragmentManager.FindFragmentById(Resource.Id.FileListFragment);
Run Code Online (Sandbox Code Playgroud)
但我在Watches for FileListFragment中得到"Unknown identifier:fileListFragment"
更新.
活动代码:
using Android.Support.V4.App;
using Android.OS;
namespace com.xamarin.recipes.filepicker
{
[Android.App.Activity(Label = "Choose file", MainLauncher = true, Icon = "@drawable/icon")]
public class FilePickerActivity : FragmentActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ChooseAudio);
var fileListFragment = (FileListFragment)SupportFragmentManager.FindFragmentById(Resource.Id.FileListFragment);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用ExpandableRecyclerView来嵌套RecyclerView.它工作得很好,除非您需要动态更新父列表.
我的项目将Product类作为父对象(并扩展ParentListItem).我从API获取产品列表,因此需要清除当前列表并添加我有的列表.
在ExpandableRecyclerAdapter中我试过这个方法 -
public void onDataChanged(ArrayList<Product> parentObjects) {
this.getParentItemList().clear();
this.getParentItemList().addAll(parentObjects);
this.notifyItemRangeChanged(0, parentObjects.size() - 1);
}
Run Code Online (Sandbox Code Playgroud)
然而,它给出了一个奇怪的通用错误
Error:(60, 33) error: no suitable method found for addAll(ArrayList<Product>)
method List.addAll(Collection<? extends CAP#1>) is not applicable
(actual argument ArrayList<Product> cannot be converted to Collection<? extends CAP#1> by method invocation conversion)
method List.addAll(int,Collection<? extends CAP#1>) is not applicable
(actual and formal argument lists differ in length)
method Collection.addAll(Collection<? extends CAP#1>) is not applicable
(actual argument ArrayList<Product> cannot be …Run Code Online (Sandbox Code Playgroud) generics android android-recyclerview expandablerecyclerview
我正在使用 Visual Studio Code 进行前端开发。我启用了sort-keys要求所有对象的键按字母顺序排列的规则。
我发现 ESLint 和 Prettier 都不支持自动修复,因为自动修复可能会引入潜在的错误,因此他们都拒绝了甚至考虑添加自动修复作为选项的提议。
现在我有一个非常大的遗留代码库,我刚刚在其中添加了 ESLint,我需要在项目中使用这个排序键规则。有什么办法可以自动修复它们,前提是我知道我在做什么,可能是通过一些 VSCode 插件或自定义脚本?
我确信更改键的顺序不会对我的代码产生负面影响。对于 JSON 对象和 JS 对象文字,我都需要它。
我正在制作一个应用程序,允许我将图像拼接成一个全景场景.我希望能够以编程方式打开iPhone 4上的闪光LED.
我怎样才能做到这一点?
我阅读了文档并发现我需要使用AVCaptureFlashMode
但我无法弄清楚2如何使用它?
任何帮助,将不胜感激.
更新了以下代码.谢谢SIF!
NSError* error = nil;
NSLog(@"Setting up LED");
if([captDevice hasTorch] == NO)
{
NSLog(@"Error: This device doesnt have a torch");
}
if([captDevice isTorchModeSupported:AVCaptureTorchModeOn] == NO)
{
NSLog(@"Error: This device doesnt support AVCaptureTorchModeOn");
}
AVCaptureSession* captureSession = [[AVCaptureSession alloc] init];
AVCaptureDeviceInput* videoInput = [[AVCaptureDeviceInput alloc] initWithDevice:captDevice error:&error];
AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init];
if (videoInput && videoOutput)
{
[captureSession addInput:videoInput];
[captureSession addOutput:videoOutput];
if([captDevice lockForConfiguration:&error])
{
if (flag == YES) {
captDevice.torchMode = AVCaptureTorchModeOn;
} else … 我在实施Jake Wharton的ViewPagerIndicator时发现了一些问题.这些是Logcat上所说的:
06-19 15:32:02.661: E/AndroidRuntime(692): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aprian.learn/com.aprian.learn.VPIndicator}: android.view.InflateException: Binary XML file line #7: Error inflating class com.viewpagerindicator.TitlePageIndicator
Run Code Online (Sandbox Code Playgroud)
我已经放置了viewpagerindicator库并且已经将它放在构建路径中,但仍然无法启动应用程序.
更新: - 似乎我必须提供返回xml的URL.这是 - URL
我在解析xml时遇到了SAXParseException.我试图解析的xml如下 -
<?xml version="1.0" encoding="utf-8"?>
<markers xmlns="">
<marker name="" address1="" address2="" region="" country="" zip="" imgsrc="" lat="" lng="" distance="" />
<marker name="" address1="" address2="" region="" country="" zip="" imgsrc="" lat="" lng="" distance="" />
<marker name="" address1="" address2="" region="" country="" zip="" imgsrc="" lat="" lng="" distance="" />
<marker name="" address1="" address2="" region="" country="" zip="" imgsrc="" lat="" lng="" distance="" />
<marker name="" address1="" address2="" region="" country="" zip="" imgsrc="" lat="" lng="" distance="" />
</markers>
Run Code Online (Sandbox Code Playgroud)
我用来解析这个xml的代码如下 -
public Document getDomElement(String xml) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Smack用于我的项目.我之前在一些早期的项目中使用了一个sSck,这些项目运行得非常好.然而,Smack给了我奇怪的例外.
这是我的初始化代码看起来像 -
public void init(String username, String password) throws IOException, XMPPException, SmackException {
mConnection = new XMPPTCPConnection(username, password, HOST_NAME); //This is the line which generates the exception
mConnection.connect();
mConnection.login();
mChatManager = ChatManager.getInstanceFor(mConnection);
mChatManager.addChatListener(this);
}
Run Code Online (Sandbox Code Playgroud)
这是Logcat输出 -
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3690)
at android.view.View.performClick(View.java:4192)
at android.view.View$PerformClick.run(View.java:17248)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at …Run Code Online (Sandbox Code Playgroud) 我在官方的Photon Server论坛上问过这个问题,但它不如这个网站那么活跃,所以可能会有人理解我在说什么,所以,如果你有时间和知识,请分享.谢谢!
来这里......
所以,我在Photon上有一个非常好的服务器工作原型和一个与服务器对话的基本Unity3D客户端.它是根据cjrgaming上的示例构建的.
客户端可以:连接,发送请求,建立和发送加密请求服务器可以:创建对等,接收操作请求,向客户端发送操作响应或事件,以及我的小增加是:如果游戏有很多操作,你不必使用一个巨大的switch case语句,而是我将操作划分为类别(Classes),并通过使用委托和字典来调用它们.
当我觉得它已经准备好发布时,我会发布一个有效的例子,但是现在,我的实际问题......(对不起,很长的帖子,我不得不解释我所知道的和迄今为止的内容):
什么是从客户端发送到服务器的实际操作?或者服务器向客户端提出的事件(所有客户端一次性?)?
起初,我认为每个操作都是游戏中特定的用户流程.例如,操作代码"1"表示玩家X想要射击玩家Y,做某事.但是,我意识到,根据字节限制,您不能将所有游戏逻辑仅放在255个操作中,而不会将其扩展为short int或其他内容.
然后我发现还有一个channelID,它可以在同一个操作代码请求上有所不同......这对我来说,操作代码不是用户流,而是客户端之间相同/类似操作的数据流和服务器,channelID可用于区分要在服务器上计算的请求操作.
然后...!我意识到(哦,假我),从客户端发送到服务器的参数,反之亦然在字典中,这增加了另一层可能的用户流.
所以..现在我想要了解一些事情,但他们只是让我更加困惑.
任何人都可以简单解释一下操作/事件/ channelID的目的吗?例如,如果你做一个小型多人游戏,你会用什么来制作用户(游戏)流,比如 - >玩家击中目标,玩家拿起世界上的物品,玩家发送消息.您是否会为每个流使用唯一的操作代码,或者您通过意义分组操作并使用通道来区分请求,或者甚至在这里,您对许多用户流使用相同的channelID,并将它们与参数中的某些ID区分开来?
希望我有任何意义.
非常感谢,至少,如果有的话,请多多帮助!