The SetVolume function reacts only on the leftVolume setting. If I set the leftVolume between 0f and 1f the left and right volume goes up and down. If I set the rigtVolume it has no impact on the output at all. This means if for exampe, I set the leftVolume to 0f and the rightVolume to 1f, I can't hear anything.
I've tested this behavior with a blue tooth inear headset and also with 3.5mm cable connected headset. In both cases the same result.
signalPlayer.SetVolume(leftVolume,rightVolume)
How can I set the volume for the right and the left channel seperately?
I have now tested the behavior with a galaxy S20. For this phone the left right control works fine. With the NOKIA 8 which I've tested before their is still this malfunctional behavior. Therefore it seems that it depends on the phone if it works.
I do not have the same version of you device. But you could the volumn after starting the player. It would work on most device.
MediaPlayer signalPlayer;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.layout1);
signalPlayer = MediaPlayer.Create(this, Resource.Raw.AMBForst_48000);
var button1 = FindViewById<Button>(Resource.Id.button1);
button1.Click += delegate
{
signalPlayer.Start();
signalPlayer.SetVolume(1f, 1f);
};
}
Related
I have a circumstance where a bluetooth barcode scanner is acting as a hardware keyboard in an Xamarin Forms application. The barcodes are encoded as such to contain a bit of information that needs to be parsed into different fields.
Unfortunately, some of the data is a tab character. iOS receives this hardware event in my app and once the tab pumps through, the next input field is focused and the barcode data continues to dump into that (the barcode scanner reads the data through "sequentially", as if to simulate you were typing it in).
At any rate; I'm having a heck of a time intercepting the "tab" character in an Entry (UITextView) in Xamarin/iOS.
I've set up an extension on Entry and associated a custom renderer with it (MyRenderer : EntryRenderer). Searching suggests that using Control.ShouldChangeTextInRange should work for character remapping, but the tab event happens on a different level it appears.
How can I stop a hardware keyboard "Tab" character in iOS from focusing onto the next field?
You could use KeyCommands to filter the Tab action in your EntryRenderer like this:
public override UIKeyCommand[] KeyCommands
{
get
{
UIKeyCommand newForwardKeyCommand = UIKeyCommand.Create(new NSString("\t"), 0, new ObjCRuntime.Selector("Excute"));
UIKeyCommand newBackKeyCommand = UIKeyCommand.Create(new NSString("\t"), UIKeyModifierFlags.Shift, new ObjCRuntime.Selector("Excute"));
UIKeyCommand[] keyCommands = { newForwardKeyCommand, newBackKeyCommand };
return keyCommands;
}
}
[Export("Excute")]
private void Excute()
{
Console.Write("Excute!");
}
Reference:https://stackoverflow.com/a/30876304/5474400
I'm a new in Unity and making my first 2D game. I seen several topics on this forum in this issue, but I didn't found the solution.
So I have a lovely shooting animation and the bullet generation. My problem, I have to generate the bullet somewhere at the middle of the animation, but the character shoots the bullet and the animation at the same time, which killing the UX :)
I attached an image, about the issue, this is the moment, when the bullet should be initialized, but as you can see it's already on it's way.
Please find my code:
The GameManager update method calls the attackEnemy function:
public void Awake(){
animator = GetComponent ();
animator.SetTrigger ("enemyIdle");
}
//if the enemy pass this point, they stop shooting, and just go off the scren
private float shootingStopLimit = -6f;
public override void attackPlayer(){
//animator.SetTrigger ("enemyIdle");
if (!isAttacking && gameObject.transform.position.y > shootingStopLimit) {
isAttacking = true;
animator.SetTrigger("enemyShoot");
StartCoroutine(doWait());
gameObject.GetComponentInChildren ().fireBullet ();
StartCoroutine (Reload ());
}
}
private IEnumerator doWait(){
yield return new WaitForSeconds(5);
}
private IEnumerator Reload(){
animator.SetTrigger ("enemyIdle");
int reloadTime = Random.Range (4,7);
yield return new WaitForSeconds(reloadTime);
isAttacking = false;
}......
My questions:
- How can I sync the animation and the bullet generation ?
Why not the doWait() works ? :)
Is it okay to call the attackPlayer method from the GameManager update ?
The enemies are flynig from the right side of the screen to the left, when they reach the most right side of the screen, they became visible to the user. I don't know why, but they to a shooting animation (no bullet generation happen )first, only after it they do the idle. Any idea why ?
Thanks,
K
I would suggest checking out animation events. Using animation events, you can call a method to instantiate your bullet.
To use Mecanim Animation Events you need to write the name of the function you want to call at the selected frame in the "Function" area of the "Edit Animation Event" window.
The other boxes are for any variables that you want to pass to that function to trigger whatever you have in mind.
Triggering/blending between different animations can be done in many different ways. The event area is more for other things that you want to trigger that are not related to animation (e.g. audio, particle fx, etc).
I have to create an animation for a Windows Phone 8.1 app. I want to change the ImageSource property of my Page.Background to display an animated splash when the app launches.
I used this sample as a model: http://www.codeproject.com/Tips/823622/Images-Animation-By-Using-Story-Board-in-Windows-P
In my code, the animation lasts 8 seconds for 80 images, but the screen stays black for 8 seconds, then only displays the last frame.
private void setupStoryboard()
{
storyboard = new Storyboard();
var animation = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(animation, BackgroundBrush);
Storyboard.SetTargetProperty(animation, "ImageSource");
storyboard.Children.Add(animation);
for (int i = 0; i <= 80; i++)
{
var keyframe = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100 * i)), //Time Interval
Value = String.Format("ms-appx:///Assets/Animation/splash{0:D2}.png", i) //Source of images
};
animation.KeyFrames.Add(keyframe);
}
Resources.Add("Storyboard", storyboard); //Add story board to resources
}
This code is called from OnNavigatedTo, and I have a button to call storyboard.Begin();
This problem appears on simulator and device.
Update: The problem persists with a greater interval (1000ms), and smaller images (30KB jpg instead of 240KB png)
Update: Same problem with an <Image> tag
Update: Still not solved, but I managed to obtain the desired effect. I created a DispatcherTimer to manually change the image. Unfortunately, this creates a nasty flickering effect. I had to add a second identical image on top of the first, and alternate between the two: imageA loads source1, imageB loads source2, imageA loads source3, ImageB loads source4...
Mission completed, with duct tape.
I'm writing a driver to handle touch events from a Planar touch screen (in OSX) using Apple's IOKit tools. The driver is able to receive x and y coordinates, but I'm having trouble figuring out which finger the coordinates belong to.
In my callback function, I'm querying the most recent value's parent to determine the finger ID, but the value is always the most recent finger – so 3 if there are 3 fingers down, 2 if there are 2 fingers down, etc., etc. Here's what callback looks like:
void touchCallback(void *context, IOReturn result, void *sender, IOHIDValueRef value) {
IOHIDElementRef element = IOHIDValueGetElement(value);
IOHIDDeviceRef device = IOHIDElementGetDevice(element);
IOHIDElementRef parent = IOHIDElementGetParent(element);
IOHIDElementRef parent2 = IOHIDElementGetParent(parent);
CFArrayRef parentChildren = IOHIDElementGetChildren(parent2);
IOHIDValueRef fingerVal;
IOHIDDeviceGetValue(device, (IOHIDElementRef)CFArrayGetValueAtIndex(parentChildren, 5), &fingerVal);
long fingerID = IOHIDValueGetIntegerValue(fingerVal);
}
Is there another recommended approach for determining which finger the x and y coordinates belong to?
Similarly, are there any recommended practices for figuring out which finger is being released?
I'm receiving events that indicate a finger has been lifted, but the numbers are inconsistent – sometimes it'll report the same finger ID 2x, other times it won't report anything. Is there a 'frame'-based approach to testing if a fingers is still down?
Thanks++ for any advice!
I'm trying to show a window in xcb, inside the main window, but actually without luck.
The idea is that when the user press a button (in that case the X button) a small white window is shown (just for test).
But actually i'm stuck on that step. I watched the example code here:
http://en.wikibooks.org/wiki/X_Window_Programming/XCB
And tried to do the same in my application.
[EDIT 28/10/2013] Now with that code i can show a window, but if i try to add other variable like int i=0, or whatever, the window doesn't appear, and no expose events were raised (all events that were raised are or 0 or 2 (even if i add the variables inside other events). Any idea?
This is the XCB_KEY_PRESS event handler code:
Edit (with the new code)
case XCB_KEY_PRESS:{
xcb_key_press_event_t *kp = (xcb_key_press_event_t *)ev;
if(kp->detail==53){
printf("X pressed\n");
uint32_t vals[2];
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
vals[0]=screen->white_pixel;
vals[1]=XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
win = xcb_generate_id(connection);
xcb_create_window(
connection,
XCB_COPY_FROM_PARENT,
win,
root,
80,80,
150,150,
10,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual,
mask, values);
mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
vals[0]=screen->white_pixel;
vals[1]=0;
background=xcb_generate_id(connection);
xcb_create_gc(connection, background, win, mask, vals);
xcb_map_window(connection,win);
xcb_flush(connection);
printf("finished\n");
}
printf("KEY_PRESS - Pressed: %d\n", kp->detail);
}
root is the root window obtained from xcb_screen_t variable.
The definition of background and win are the following:
xcb_window_t win;
xcb_gcontext_t background;
And i added even a XCB_EXPOSE event handler:
case XCB_EXPOSE:{
printf("EXPOSE NEW WINDOW CREATED\n");
xcb_poly_fill_rectangle(connection, win, background,1,&rectangle);
xcb_flush(connection);
}
What is wrong with that code? What am i missing? (I'm trying to develop a very basic window manager, just for fun)
(My idea for that program is that when x is pressed an input box is shown, do you have any suggestion on how to do that?)