gotoAndPlay not working! AS3 - android

Thank you for looking at my post. So I was going to make an AIR for Android game, so I got to work, and, well heres the problem.
stop();
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
btn_Play.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_2);
function fl_TapHandler_2(event: TouchEvent): void
{
gotoAndPlay(91);
}
When ever I tap the btn_Play, it just goes to Frame 1 and plays. BTW this is on Frame 90. Please help!

if you have only 90 frames and you define
gotoAndPlay(91);
you will go to frame 1, change to:
gotoAndPlay(90);
if you have more than 90 frames probably you need to read this:
http://www.kirupa.com/forum/showthread.php?335765-gotoAndPlay%28%29-and-frame-script-stop%28%29

Have you wrote stop() method at end of the frame? if not try this at end of the frame or how many frames are you using kindly check that.
stop()

Related

In Quickblox, how can we rotate a video (90 degrees, for example) in Android app (QBRTCSurfaceView)?

We are streaming a video chat using Quickblox and we'd like to be able to rotate it (90, 180, 270 degrees).
In the iOS SDK this seems possible, but with Android there doesn't seem to be a setting. How can we get around this and display the video rotated? Thanks!
You can use a View method : void setRotation (float rotation) like below :
your_vide_view.setRotation(90f);
or
your_vide_view.setRotation(180f);
or
your_vide_view.setRotation(270f);
this method work for sdk >15
you should also add this condition :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
your_vide_view.setRotation(180f);
}
This may be too late, but for anyone wondering how to rotate the video view, you can get the video track and call addSink() function to retrieve each frame. You can then rotate the frames and call onFrame() function on the videoview. Please find the sample code below.
Remove any renderers before adding the below code and also do not add any renderers because the below code will do that.
localVideoTrack?.track?.addSink { videoFrame->
localVideoView.onFrame(VideoFrame(videoFrame.buffer, 90, -1))
}

How add frame around video

I'm developing app in which I need to create video with frame around it. So, basically i get video throuh standart camera and then I need to add frame around it. On the picture my video needs to be instead of blue area;
I have already read a tons of information about video processing and post-processing, opencv, ffmpeg etc. Does anyone knows how I can achieve this ?
After many hours I found only one solution - to use ffmpeg. You can build it and use through android jni. In my case I used executable ffmpeg file. In OnCreate I'm installing it from raw and then using its functions. (There are many solutions in the internet and on the StackOverflow about ffmpeg commands)
This is very simple.
Try to understand what I have written.
PImage frame, temp;
void setup()
{
/*Display your frame here*/
frame = get(); // this will capture the screen
}
void movieEvent(Movie m)
{
m.read();
frame.copy(m, 0, 0, m.width, m.height, Xbluestart, Ybluestart, Xblueend, Yblueend);
}
void draw()
{
Image(frame, 0, 0);
}
I think this would slove your problem.
P.S. instead of writing Xbluestart or Xblueend; write the co-ordinates of blue rectangle in there.

my line of code is not executing in delay - android

The strangest thing is happening. In my onClick(View ...) I have blocks of code, mostly 'if/else' blocks. The sequence is (in pseudo-code, to save you lengthy code):
I have an image that needs setting using imageButton.setImageResource(randomImage); then
I have a MediaPlayer associated with this image that needs playing, then
I place a sleep(1800) here otherwise the MediaPlayer runs into the next MediaPlayer (this works fine)
This image is compare to another image. If its not the same, then another MediaPlayer named 'boo' is played, and the image that should have been displayed in code 1. above, is replaced by 'flag' image. else //if its the right image then
Switch to 'another' image, play it's corresponding MeidaPlayer, Play a 'cheers' MediaPlayer and change image to a 'tick' image, then do some other logic stuff.
But what is happening is that the code 2. is playing, code 3. is happening. code 4. only the 'boo' mediaplayer is happening and I notice the imagebutton flashing. The image that was supposed to be set in code 1. is delayed and is happening only AFTER the 'boo' mediaplayer. The 'flag' image that replaces the first image setting in code 1. is happening but because code 1. is in delay, what is happening is that the image is not changing (although it is, it's just in delay and then it flashes so quickly that it appears not to change). So code 1. is in delay.
Also, if it goes into the else and the right image is clicked, then the image in code 5. DOES switch to 'another', but the corresponding MeidaPlayer doesn't play, the 'cheers' MediaPlayer doesn't play, the 'tick' image doesn't display, and the other logic doesn't occur. Its as if it is ignoring the code.
What's happening here? Is this a multi-threading situation here? Grouping different parts of the code in their own threads and starting them at once only throws exceptions. Any help will be greatly appreciated!
If you want to delay your code, use Handler.postDelayed(Runnable, long). This won't block the UI thread, and will execute when you want it to.
Whitout your code, it's really unclear what are you trying to achive, and how are you trying to achieve it.
Just to explain Adam's idea.
Put this in your Activity class :
final Handler handler = new Handler();
Runnable _rnbl = new Runnable() {
public void run() {
// Your code
}
};
And call it like this
handler.postDelayed(_rnbl , 5000);

AndEngine - lagging when playing sound

I'm creating a simple game with AndEngine. A ball is dropped toward a floor, and whenever it collides with the floor, I want to play a short colliding sound. In method onUpdate(), I check for collision and play sound accordingly.
I use class Sound for playing sound (as in the SoundExample of AndEngine). Testing on Samsung Galaxy S2.
The problem is the program gets lagged when the sound is played. And it even affects game physics (sometimes the ball bounces higher than the highest point when disabling sound).
This is the code:
public void onUpdate(float pSecondsElapsed) {
// mSound.play();
if (this.mSprite.collidesWith(ball.getSprite())) {
if (!colliding && mSound != null){ // play sound for first collision only
mSound.play();
colliding = true;
}
}
else{
colliding = false;
}
}
If I remove mSound.play() or keep playing sound (remove comment at line 2), the program works smoothly.
Does anyone encounter the same problem? And have a solution to get rid of the lag? Many thanks!
as that you mentioned that it works smoothly when you keep playing the sound .. then the problem is not with the sound
the collidesWith() method is probably your culprit, remember that onUpdate gets called every frame .. maybe you'll have to redesign your code or limit the number of frames per second [change your engine options to use a FixedStepEngine to achieve that]

Android Camera.takePicture - Possible to disable shutter sound and preview surface?

I am working on an app that will allow a user to take quick click and forget snapshots. Most of the app is done except for the camera working that way I would like. Right now I have the camera working but I can't seem to find a way to disable the shutter sound and I cant find a way to disable displaying the preview. I was able to cover the preview up with a control but I would rather just not have it displayed if possible.
To sum things up, these are the items that I would like to disable while utilizing the built in Camera controls.
Shutter sound
Camera screen display
Image preview onPictureTaken
Does anyone know of a resource that could point me in the right direction, I would greatly appreciate it. I have been following CommonsWare's example from this sample fairly closely.
Thank you.
This is actually a property in the build.prop of a phone. I'm unsure if its possible to change this. Unless you completely override it and use your own camera code. Using what you can that is available in the SDK.
Take a look at this:
CameraService.cpp
. . .
CameraService::Client::Client(const sp<CameraService>& cameraService,
const sp<ICameraClient>& cameraClient,
const sp<CameraHardwareInterface>& hardware,
int cameraId, int cameraFacing, int clientPid) {
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
mOrientationChanged = false;
cameraService->setCameraBusy(cameraId);
cameraService->loadSound();
LOG1("Client::Client X (pid %d)", callingPid)
}
void CameraService::loadSound() {
Mutex::Autolock lock(mSoundLock);
LOG1("CameraService::loadSound ref=%d", mSoundRef);
if (mSoundRef++) return;
mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");
mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");
}
As can be noted, the click sound is started without your interaction.
This is the service used in the Gingerbread Source code.
The reason they DON'T allow this is because it is illegal is some countries. Only way to achieve what you want is to have a custom ROM.
Update
If what being said here: http://androidforums.com/t-mobile-g1/6371-camera-shutter-sound-effect-off.html
still applies, then you could write a timer that turns off the sound (Silent Mode) for a couple of seconds and then turn it back on each time you take a picture.
You may use the data from the preview callback using a function to save it at a picture on some type of trigger such as a button, using onclick listener. you could compress the image to jpeg or png. In this way, there no shutterCallback to be implemented. and therefore you can play any sound you want or none when taking a picture.
You can effectively hide the preview surface by giving it dimensions of 1p in the xml file (I found an example the said 0p but for some reason that was giving me errors).
It may be illegal to have a silent shutter in some places, but it doesn't appear that the US is such a place, as my HTC One gives me an option to silence it, and in fact, since Android 4.2 you can do this:
Camera.CameraInfo info=new Camera.CameraInfo();
if (info.canDisableShutterSound) {
camera.enableShutterSound(false);
}

Categories

Resources