control the server side media volume in android - android-mediaplayer

switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
Toast.makeText(getApplicationContext(), "testrise", Toast.LENGTH_LONG).show();
audio.adjustStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE,
AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
Toast.makeText(getApplicationContext(), "testlow", Toast.LENGTH_LONG).show();
audio.adjustStreamVolume(AudioManager.STREAM_RING,
AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
return true;
default:
return false;
This is a code i tried do far...I successfully implement this ..it control only sounds in device..in my sceneraio i have to control the media that come from server..so not able to control the volume by using this code

Related

AVFoundation AutoExposure

I'm developing camera app right now.
I finished most of important features but the most important feature left.
I want my app auto exposure mode.
Here is my sample.
do {
try camera.lockForConfiguration()
camera.focusMode = .continuousAutoFocus
camera.exposureMode = .continuousAutoExposure
camera.unlockForConfiguration()
} catch {
return
}
I made this setting between lockForConfiguration and unlockForConfiguration.
This lead to autoexposure, however it is different from native camera app.
Also, shutter speed does not go below 1/40.
It is always 1/40 whenever it is in dark environment.(where native camera app adjust shutter speed to 1/2 or even 1)
I found the answer here (https://developer.apple.com/forums/thread/26227)
But I don't understand this answer and even how to do that...
session.beginConfiguration()
defer {
session.commitConfiguration()
}
device = AVCaptureDevice.default(.builtInDualWideCamera, for: .video, position: .back)
guard let camera = device else {
set(error: .cameraUnavailable)
status = .failed
return
}
I set AVCapturedevice in this code. Also there is a session.
The answer says don't touch sessionpreset, so I did do anything by sessionPreset.
But how can I set the avcapturedevice by activeformat..?
This is very hard to understand.
Just to check if this is work, I added this codes just below above codes.
'''
var bestFormat: AVCaptureDevice.Format?
bestFormat = device!.formats[2]
print(self.device?.formats)
do {
try camera.lockForConfiguration()
camera.focusMode = .continuousAutoFocus
camera.exposureMode = .continuousAutoExposure
camera.activeFormat = bestFormat!
// camera.setExposureModeCustom(duration: CMTime(value: 1, timescale: 500), iso: 2000)
camera.unlockForConfiguration()
} catch {
return
}
'''
I believe this does not work because camera-resolution doesn't change.
even if device!.formats[2] is low resolution for me (I checked it)

Switch to top-level frame with Selenium

What is the best way to switch to the top-level frame in Selenium if I'm unsure of the nesting level?
I tried using this code, but ParentFrame() doesn't throw an exception if you are already at top-level so it doesn't work.
while (true)
{
try { driver.SwitchTo().ParentFrame(); } catch { break; }
}
If you want to return to the main content from Iframe use this
driver.switchTo().defaultContent();

Xamarin camera not on main navigation page

I've managed to get the camera going cross platform using xamarin and this tutorial:
Camera access with Xamarin.Forms
I'm now trying to get it working on a different navigation form (The camera functionality would be several forms away from the main page.) However the device specific code accesses many things wired up to the App instance which I'm struggling to wire up from another form. Does anyone know of a good camera example that isn't on the main page? I've been coding C# for years but I'm new to Xamarin and the camera stuff seems to be the hardest to get going. Thanks in advance.
Jeff
use the Media plugin
takePhoto.Clicked += async (sender, args) =>
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});
if (file == null)
return;
await DisplayAlert("File Location", file.Path, "OK");
image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
};

How to continue webdriver/selenium after error

I'm doing a test bot with webdriver. I have a scenario where it clicks on a button, a new windows open, and it searches for an element by a specific xpath, but sometimes there is no such element because it can be disabled and i get this error: org.openqa.selenium.NoSuchElementException. How can i bypass it/continue the bot so it just closes the new windows if it doesn't find the element with that xpath and just continue with the code?
In Java :
List<WebElement> foundElement = driver.findElements(By.xpath("<x-path of your element>"));
if (foundElement.size() > 0)
{
// do whatever you want to do in **presence** of element
} else {
// do whatever you want to do in **absence** of element
}
You need to surround the click event with a try/catch statement, and inside the catch statement check if the exception is the one you are trying to bypass:
try {
driver.findElement(by).click();
} catch(Exception e) {
if ( !(e instanceof NoSuchElementException) ) {
throw e;
}
}

Play and pause functions works only once

I'm viewing the live streams using the flash player. while i'm doing that i have tried to play and pause the streams using the following function but it is only works for only one click. if i'm re-clicking it does not shows any changes. If you realize my problem. please suggest me.
function testPause(event:MouseEvent) {
nsPlay.pause();
}
function testPlay(event:MouseEvent) {
if(!bolLoaded) {
nsPlay.play(streamValue);
bolLoaded = true;
} else {
nsPlay.resume();
}
}
Make Boolean variable value FALSE in pause state.
bolLoaded = false;