Anyway to place camera preview onto xml defined surfaceview?

by chrispix » Tue, 16 Dec 2008 06:05:13 GMT


Sponsored Links
 I have been messing with the issue for days to try and place the
camera preview onto a surfaceview defined in my xml layout. Main
reason I am trying to do this is to place it onto a tabview.

used to tie to the surface view to paint.
So on the Preview API  example, if I changed it from
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
to
SurfaceView mysurfaceview = (SurfaceView)findViewById
(R.id.SurfaceView01);
mHolder = mysurfaceview.getHolder;
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

My app compiles fine, but crashes @ runtime.

That should work, but I don't think I have seen an application YET
where the camera preview is loaded onto a SurfaceView. I am able to
resize the preview using the width and height, but that does not
really help as I can't seem to position the view where I need it to
be.


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Help - adb cant' see running emulators, emulator can't connect to internet

Hi All,

I got those two problems. Both exist only on my primary development
comp, which is running Windows 7 64bit.
Using Eclipse 3.5, jdk 6.20 (tried everything with jdk 6.19 too),
latest android sdk.
Windows firewall is off, comodo firewall is running, and windows
security essentials too.
Comodo policies allow all incoming and outgoig communication of any
type for both, adb and emulator. And javaw.exe as well.
In fact, I have both problems with disabled comodo and wse as well.

1) adb doesn't detect emulators that were launched after adb. In other
words if I run adb and then the emulator, which is the case in
eclipse, adb devices command returns empty list. If I restart adb, or
launch emulator from the command line and then run adb, it is working,
adb devices returns emulator5554:name just fine.

2) Emulator can't connect to internet, browser says "no network
connection"
I've tried to specify dns server using emulator.exe -dns-server
192.168.0.1 -avd A22 command, I get the error - ### WARNING: can't
resolve DNS server name '192.168.0.1', even though that's the dns
returned by ipconfig /all. Second line of the message says, will use
default DNS server, which in verbose log turns out to be the same
192.168.0.1....
Specifying DNS servers of my ISP doesn't help either, I get the same
warning.
Enabled verbose logging, but no error is reported there. I can post
that log if it helps to resolve the problem.

What I already tried few times:
Remove eclipse, jdk and android SDK completely; disable firewall and
AV; install jdk; eclipse; update eclipse; install android sdk; install
eclipse plugin;

Same installation procedures and settings work fine on two other
computers, one is a desktop, another is a laptop, but both are running
windows XP, one SP2, another SP3.
So, I am assuming the problem is with Win7 64.
One thing I found is that my win7 installation has hosts file not
under \windows\system32\drivers\etc, nor under \Windows
\SysWOW64\drivers but somewhere in \Windows\winsxs\amd64_microsoft...
which is weird, but the documentation I found about emulator behavior
states that hosts file is ignored, and instead the emulator gets its
data using windows GetNetworkParams() API call.

Any suggestions how to resolve any of those two?

-- 

2. AudioTrack: obtainBuffer timed out question

Hi,

I am using the eyes free TTS framework, and am observing a repeatable
1 second lag in the AudioTrack output that I am trying to explain.

The problem occurs after the first or second callback (ttsSynchDoneCB,
see: frameworks/base/packages/TtsService/jni/
android_tts_SynthProxy.cpp).
The underlying tts engine seems to be producing the callbacks fast
enough, but for some reason there is a 1 second pause before playback.
I see the following warning message in logcat:

  W/AudioTrack( 1262): obtainBuffer timed out (is the CPU pegged?)
  0x11f650 user=0000894a, server=0000794a

That message from AudioTrack is coming right after executing a line
that looks like the following:
  result = cblk->cv.waitRelative(cblk->lock,
milliseconds(waitTimeMs));

The value of waitTimeMs is 1 second, which is the delay I am seeing.
I do not understand the cause of the delay however; the code calls
obtainBuffer, and the message happens only if "framesAvailable" equals
0.  I don't understand what framesAvailable means in this context,
however, since it is during a call to AudioTrack::write that this is
happening, and there is certainly something available to write.

Can someone describe why this delay is occurring, and if there is
anything I can try to get rid of it?  Note that the CPU is certainly
not pegged, the only thing going on at the time is the tts.


Thanks,
-Mark

-- 

3. receive message from server

4. Submit your Android app

5. WebSettings.ZoomDensity not working

6. How to get the point from click the google map

7. Savin a class to SD