surfaceview

Options to efficiently draw a stream of byte arrays to display in Android

旧时模样 提交于 2019-12-06 04:23:26
问题 In simple words, all I need to do is display a live stream of video frames in Android (each frame is YUV420 format). I have a callback function where I receieve individual frames as a byte array. Something that looks like this : public void onFrameReceived(byte[] frame, int height, int width, int format) { // display this frame to surfaceview/textureview. } A feasible but slow option is to convert the byte array to a Bitmap and draw to canvas on SurfaceView. In the future, I would ideally

Android版OpenGL游戏引擎的集成KeyMob管理库教程

寵の児 提交于 2019-12-06 00:25:05
一:前提条件 1:下载适用于 Android的Google移动广告SDK 二:OpenGL游戏---横幅广告 如果您使用基于OpenGL的游戏引擎,但使用原生的 Android集成广告,我们建议您仅在游戏暂停或结束时,或者在用户未主动玩游戏的屏幕上展示横幅广告。这样做的优势在于: 1:更好的用户体验---用户不希望在玩游戏的过程中被广告干扰 2:效果---广告可能会影响游戏的帧速率 3:防止出现意外点击 以下示例说明如何使用最少的代码添加横幅广告。在适当的时间加载横幅广告则是您的责任。 三:Android 大部分基于OpenGL的Android游戏都使用SurfaceView的形式。您的主活动如下所示: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SurfaceView gameView = new SurfaceView(this); setContentView(gameView); } } 以下示例使用RelativeLayout将智能横幅广告固定在屏幕底部。 public class MainActivity extends

ANR in SurfaceView method “onTouchEvent(…)” on Android

核能气质少年 提交于 2019-12-05 22:09:53
On Android, I've subclassed SurfaceView and the resulting view is working fine in most cases. However, roughly 1% of all users report an ANR problem with this implementation. Apparently, there's an edge case where the SurfaceView fails due to some problem, probably a deadlock. Unfortunately, I don't know what's wrong with my implementation of onDraw(...) and onTouchEvent(...) or how to improve the code. Can you help? "main" prio=5 tid=1 MONITOR | group="main" sCount=1 dsCount=0 obj=0x41920e88 self=0x4190f8d0 | sysTid=13407 nice=0 sched=0/0 cgrp=apps handle=1074618708 | state=S schedstat=(

How to use camera live feed as a activity background?

时光毁灭记忆、已成空白 提交于 2019-12-05 21:33:59
问题 I am trying to make an App in which I need to use camera live feed as a background. (I know its a stupid thing to do but can't help, its a client demand). I have tried doing it using SurfaceView but no success so far. So far whatever I found on Stack Overflow are more of a guesses or directions how to do it but no real time examples or code help is out there. It would be great if someone who has done this before share a piece of code with Stack Overflow users like me. 回答1: Take a look here:

How to get HTML5 video URI in HTML5VFullScreen$SurfaceVideoView in Android 4.0?

↘锁芯ラ 提交于 2019-12-05 20:54:12
问题 I am trying to get a HTML5 video URI when the user clicks the fullscreen button in the video control bar. According to this, the HTML5 video view in Android 4.0 is a SurfaceView, not a VideoView. Could someone tell me how to get the URI in SurfaceVideoView? This is my code. Thanks a lot. webView.setWebChromeClient(new WebChromeClient(){ @Override public void onShowCustomView(View view, CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout){

Rendering camera into multiple surfaces - on and off screen

末鹿安然 提交于 2019-12-05 20:43:44
I want to render the camera output into a view and once in a while save the camera output frame to a file, with the constraint being - the saved frame should be the same resolution as the camera is configured, while the view is smaller than the camera output (maintaining the aspect ratio). Based on the ContinuousCaptureActivity example in grafika , I thought the best approach would be to send the camera to a SurfaceTexture and generally rendering the output and downscaling it into a SurfaceView , and when needed, render the full frame into a different Surface that has no view, in order to

Change size of Android custom SurfaceView

╄→尐↘猪︶ㄣ 提交于 2019-12-05 18:46:11
I'm trying to create a 2D game engine for an Android app. I've followed this tutorial , which works fine for creating a full screen display, but I don't want that. I want to make my view take the top 2/3 (or whatever) of the screen, and fill the bottom third with standard Android widgets (buttons, text entry, etc.). I cannot get this to work. The best I can get is a blank white screen. I've tried many permutations, including using an outer LinerLayout, then embedding the custom SurfaceView inside a nested RelativeLayout, and putting the Android widgets in a nested LinearLayout, and it doesn't

Low FPS with android SurfaceView

不想你离开。 提交于 2019-12-05 17:03:14
I have some trubles with my framerate using a SurfaceView. Im doing the tipical stuff i found in some tutorials (all of them said the same), but i cant reach a decent framerate on my samsung galaxy S (the old one, i9000). Here's the code i have for the loop thread. FPS is initialized at 30. @Override public void run() { long ticksPS = 1000/FPS; long startTime; long sleepTime; //fps checker long contms=0; long lasttimecheck = System.currentTimeMillis(); int fps=0; while (running) { long time = System.currentTimeMillis(); if(contms>1000) { Log.v("FPS",String.valueOf(fps)); contms=time

Is it possible to manually destroy SurfaceView?

纵然是瞬间 提交于 2019-12-05 13:03:23
My SurfaceView is not getting destroyed even if onPause of the activity is called. I am taking care of the thread in public void surfaceCreated(SurfaceHolder holder) { if (mGameThread.getState() == Thread.State.TERMINATED) { createGameThread(getHolder(), getContext()); } mGameThread.setRunning(true); mGameThread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; mGameThread.setRunning(false); while (retry) { try { mGameThread.join(); retry = false; } catch (InterruptedException e) { } } } As an hack I have to check the state of the thread in onResume and if

Why “SurfaceView” is slower than a custom “view”?

前提是你 提交于 2019-12-05 11:23:27
I am developing an application that is almost completed. But I have some problems with graphics: Initially I used a custom "View", but had trouble handling the time in different resolutions of devices. Also the animation was not smooth. So there reading some examples and reviews, I decided to use "SurfaceView". Now the animation is smooth, but everything is slower than with a "View". I do not know why, since I did not change practically nothing when migrated from "View" to "SurfaceView": In "View" (+90 fps): @Override public void run(){ for(;;){ if(gameState == PLAYING) updatePhisic();