我正在使用Android vision API中的FaceTracker示例.但是,我在录制视频时遇到了困难,同时在它们上面绘制了叠加层.
一种方法是将位图存储为图像并使用FFmpeg或Xuggler将它们合并为视频,但我想知道如果我们可以在预计投影时在运行时录制视频,是否有更好的解决方案.
更新1: 我使用媒体记录器更新了以下类,但录制仍然无法正常工作.当我调用triggerRecording()函数时抛出以下错误:
MediaRecorder:以无效状态调用:4
我在清单文件中有外部存储权限.
更新2:
我在代码中修复了上述问题,并在onSurfaceCreated回调中移动了setupMediaRecorder().但是,当我停止录制时,它会抛出运行时异常.根据文档,如果没有视频/音频数据,将抛出运行时异常.
那么,我在这里错过了什么?
public class CameraSourcePreview extends ViewGroup {
private static final String TAG = "CameraSourcePreview";
private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
ORIENTATIONS.append(Surface.ROTATION_0, 90);
ORIENTATIONS.append(Surface.ROTATION_90, 0);
ORIENTATIONS.append(Surface.ROTATION_180, 270);
ORIENTATIONS.append(Surface.ROTATION_270, 180);
}
private MediaRecorder mMediaRecorder;
/**
* Whether the app is recording video now
*/
private boolean mIsRecordingVideo;
private Context mContext;
private SurfaceView mSurfaceView;
private boolean mStartRequested;
private boolean mSurfaceAvailable;
private CameraSource mCameraSource; …
Run Code Online (Sandbox Code Playgroud) android android-camera android-mediarecorder google-vision android-vision
我试图在Android中使用RxJava实现异步任务.我尝试了以下代码,但它没有用.它在UI线程上执行.我使用的是以下版本的RxAndroid 0.24.0.
try {
Observable.just(someMethodWhichThrowsException())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(s -> onMergeComplete());
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但是,以下对我来说是异步的.
Observable observable = Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
try {
someMethodWhichThrowsException();
} catch (IOException e) {
e.printStackTrace();
}
subscriber.onCompleted();
}
});
observable.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe();
Run Code Online (Sandbox Code Playgroud)
我想了解以下内容:1.它们之间有什么区别?2.创建异步任务时的最佳做法是什么?
提前致谢.
我正在尝试在集成Youtube Android SDK时避免使用Youtube Pre-Rolls.有什么办法可以避免吗?
我知道有一个条款:
"不鼓励或为您的用户或其他第三方创建功能:修改,替换,干扰或阻止YouTube在YouTube数据,YouTube视听内容或YouTube播放器中投放的广告;"
https://developers.google.com/youtube/terms
但是,在查看以下网站推荐的一些应用程序后,例如5by.在任何Youtube视频之前,我都没有看到他们播放任何广告.
http://apiblog.youtube.com/2012/12/no-webview-required-with-native-youtube.html
如果有人有想法绕过目标视频之前的Youtube广告,那就太好了.
最后,无论如何(即使是盗版问题),我想了解一下,像5by这样的应用程序如何能够绕过在目标视频之前播放的广告.
youtube android youtube-api android-youtube-api youtube-data-api
我通过Android中的分享对话框在FB上分享视频.分享完美无缺.但是,FB post id返回null.即使在上传视频之前,回调也会返回.如果我遗漏了什么,请告诉我.以下是我的代码.
public class TestFragment extends Fragment {
private CallbackManager callbackManager;
private ShareDialog shareDialog;
public TestFragment() {
// Required empty public constructor
}
public static TestFragment newInstance(String path, String json) {
TestFragment fragment = new TestFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getActivity());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
// this part is optional
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
Timber.d("result.getPostId() :: " + result.getPostId());
}
@Override
public void onCancel() …
Run Code Online (Sandbox Code Playgroud) 我编写了一个Singleton类来管理iAds.iAds在用户不活动5秒后弹出.该idleTimerExceeded调用生成一个通知,显示iAd的.这段代码适合我的要求,但由于我是iOS开发的新手,我的应用程序有时会在集成此代码后意外挂起.这段代码会产生很多警告等.我想在内存和性能方面优化我的代码.
我非常感谢您的善意建议和评论.
以下是我的代码:
iAdSingleton.h
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
#import "iAd/iAd.h"
@interface iAdSingleton : UIViewController<ADBannerViewDelegate> {
ADBannerView *adView;
UIViewController *displayVC;
NSTimer *idleTimer;
BOOL isItFirstTime;
}
@property (nonatomic, retain) ADBannerView *adView;
@property (nonatomic, retain) UIViewController *displayVC;
@property (nonatomic) BOOL isItFirstTime;
+ (id) shareAdSingleton;
- (void) resetIdleTimer;
- (void) idleTimerExceeded;
@end
Run Code Online (Sandbox Code Playgroud)
iAdSingleton.m
#import "iAdSingleton.h"
@implementation iAdSingleton
static iAdSingleton* _sharedAdSingleton = nil;
BOOL bannerVisible = NO;
BOOL controlAccessBannerVisibility = NO;
@synthesize adView, displayVC;
@synthesize isItFirstTime;
#define kMaxIdleTimeSeconds 5.0
+(id)sharedAdSingleton
{
@synchronized(self)
{ …
Run Code Online (Sandbox Code Playgroud) 严格模式会引发以下情况:在附加的堆栈跟踪中获取资源但从未释放.有关避免资源泄漏的信息,请参阅java.io.Closeable:
**response = httpclient.execute(httpPost);**
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
HttpClient httpclient = new DefaultHttpClient();
String url = "example";
HttpPost httpPost = new HttpPost(url);
HttpResponse response;
String responseString = "";
try {
httpPost.setHeader("Content-Type", "application/json");
**response = httpclient.execute(httpPost);**
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
responseString = out.toString();
} else {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return responseString;
Run Code Online (Sandbox Code Playgroud)
提前致谢.
java android inputstream bytearrayoutputstream android-strictmode
我在执行此代码时收到ConcurrentModificationException.我无法弄清楚它为什么会发生?
private void verifyBookingIfAvailable(ArrayList<Integer> list, int id) {
Iterator<Integer> iterator = list.iterator();
while (iterator.hasNext()) {
int value = iterator.next();
if (value == id) {
int index = list.indexOf(id);
if (index != -1) {
list.remove(index);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我被困在一个特殊的场景中。用户从应用程序更新时间后,我需要立即更新我的小部件。我确实通过发送Intent Extras数据来尝试广播,但是没有这样做。当前,我的数据存储在AppWidgetProvider中,我需要将此数据发送到服务
公共类CountdownWidget扩展了AppWidgetProvider {// SharedPreferences userDefaults;
// update rate in milliseconds
public static final int UPDATE_RATE = 1800000; // 30 minute
public static String nameOne = "";
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
setAlarm(context, appWidgetId, -1);
}
super.onDeleted(context, appWidgetIds);
}
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle extras = intent.getExtras();
nameOne = extras.getString("NAME_ONE");
Log.e("Name: ", nameOne);
super.onReceive(context, intent);
}
@Override
public void onUpdate(Context context, AppWidgetManager …
Run Code Online (Sandbox Code Playgroud) 我想添加以下代码.
if (Config.DEBUG) {
// do something
} else {
// do something
}
Run Code Online (Sandbox Code Playgroud)
我意识到在API 14中不推荐使用Config.DEBUG.如果是这样的话会有什么替代方案?
在我的 firebase 项目中,我实现了 Google 身份验证。
我的 Firebase 规则如下所示:
{
"rules": {
"users": {
"$uid": {
".read": "auth.uid == $uid",
".write": "auth.uid == $uid"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
每次我尝试模拟。Firebase 说“模拟读取被拒绝”。
我在这里做错的任何想法?
firebase firebase-security firebase-authentication firebase-realtime-database
android ×7
java ×2
arraylist ×1
facebook ×1
firebase ×1
iad ×1
inputstream ×1
ios4 ×1
ios5 ×1
list ×1
listiterator ×1
rx-java ×1
xcode4 ×1
youtube ×1
youtube-api ×1