How to create Mega zoom camera? - android

I am working on android app where i want to increase the Zoom level of camera. Actually i want to make the camera zoom like the Google Play Store app mention in the link.
Mega zoom camera android app
I can use the Mobile phone zoom feature but it is very low if i compare it with the zoom function provided in the above given app.
Below is the code where i control zoom with zoom-control button
zoomSeekBar.setOnSeekBarChangeListener(null);
zoomSeekBar.setMax(preview.getMaxZoom());
zoomSeekBar.setProgress(preview.getMaxZoom()-preview.getCameraController().getZoom());
zoomSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
preview.zoomTo(preview.getMaxZoom() - progress);
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});

Related

Why volume is not changing when app is running background?

This app is working fine when the app is opened or the app is on the screen. Volume is changing when app activity is opened. But when app is running on background, volume is not changing with slider. If I set the stream to alarm/ringtone, it works fine. But I am facing problem when the stream mode is Music. This code also works on android 11 or less. But it only facing problem with android 12. How can I run the program on android 12?
audioManager = (AudioManager) alarm_service.this.getSystemService(Context.AUDIO_SERVICE);
set_sound=customView.findViewById(R.id.sound_line);
set_sound.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_SHOW_UI);
v.vibrate(20);
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
seekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
seekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
seekBar.getProgressDrawable().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
seekBar.getThumb().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
}
});

Android: Need app's Audio Volume Seekbar to change totally independed of the device volume

I need my in-app volume seekbar to change the volume of the audio in my app only. I need it to be totally separate from the main volume of the device. Everything I find changes the device volume when I change the slider in my app.
I want users to have the option of playing audio in my app at a low volume, but maybe still have their device turned up so phone calls and alarms and such could still be at their normal high volume.
How can I make a seekbar in my app only control audio in my app and not bother other device volumes? Here is the code I am using:
Called in onCreate method:
VolumeControls();
Outside of that:
private void VolumeControls() {
final TextView txtView = (TextView)findViewById(R.id.textView1);
SeekBar seekBar = (SeekBar)findViewById(R.id.sbVolume);
final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
seekBar.setMax(audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekBar.setProgress(audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC));
txtView.setText(String.valueOf(audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC)));
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar arg0){
}
public void onStartTrackingTouch(SeekBar arg0){
}
public void onProgressChanged(SeekBar arg0, int progress, boolean arg2)
{
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
progress, 0);
txtView.setText(String.valueOf(progress));
}
});
}

Setting the ring stream volume on android 2.3 doesn't actually change the volume

I'm using seekbars to adjust the ringtone volume, but it doesn't seem to work on gingerbread. It works fine on 4.1.
ringerVlmSeekBar
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar arg0) {
}
public void onStartTrackingTouch(SeekBar arg0) {
}
//When progress level of seekbar2 is changed
public void onProgressChanged(SeekBar arg0,
int progress, boolean arg2) {
audioManager.setStreamVolume(
AudioManager.STREAM_RING, progress, 0);
}
});
Well since I didn't get any answers or comments, here's the reason that I discovered: different versions of android have different ways of linking the audio streams, which means that on my android 2.3 device, you can't change the notification volume and ringer volume independently. Hopefully this will help anyone who has this same issue.

Taking control of the MediaController progress slider

I need to catch touch events to the MediaController progress slider, so that updates to the MediaPlayer don't occur until the finger lifts off the slider.
[ Perhaps my situation is unique: I am playing streaming video that comes in multiple "stacks" for each "program". The next stack is not loaded until the previous one is finished. The slider needs to represent the duration of all stacks, and the progress of the "thumb" needs to represent total duration. This is easily done by overriding the getBufferPercentage(), getCurrentPosition(), and getDuration() methods of MediaPlayerControl ]
More problematic is "scrubbing" (moving the thumb) back and forth along the timeline. If it causes the data source to be set multiple times along with a seekTo for every movement, things very quickly bog down and crash. It would be better if the MediaPlayer did no action until the user has finished the scrub.
As others have written, Yes it would be best to write my own implementation of the MediaController. But why redo all that work? I tried extending MediaController, but that got complicated quickly. I just wanted to catch the touch events to the slider!
One is able to get a handle to the elements of MediaController:
final int topContainerId1 = getResources().getIdentifier("mediacontroller_progress", "id", "android");
final SeekBar seekbar = (SeekBar) mController.findViewById(topContainerId1);
Then set a listener on the seekbar, which will require you to implement its three public methods:
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// Log.i("TAG", "#### onProgressChanged: " + progress);
// update current position here
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Log.i("TAG", "#### onStartTrackingTouch");
// this tells the controller to stay visible while user scrubs
mController.show(3600000);
// if it is possible, pause the video
if (playerState == MPState.Started || playerState == MPState.Paused) {
mediaPlayer.pause();
playerState = MPState.Paused;
}
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
int seekValue = seekBar.getProgress();
int newMinutes = Math.round((float)getTotalDuration() * (float)seekValue / (float)seekBar.getMax());
// Log.i("TAG", "#### onStopTrackingTouch: " + newMinutes);
mController.show(3000); // = sDefaultTimeout, hide in 3 seconds
}
});
Caveats:
This is not updating the current position as you scrub, the left-hand-side TextView time value. (I had a truly remarkable way to do this which this margin is too small to contain).

How to set seek bar value in Android?

Im developing one application which used SeekBar to control volume in
MediaPlayer. The problem is when i move the seek bar at that time only the
volume is increased, rest of
the time default volume was set. Here is my code
seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser)
{
//Log.i("Seek Bar", "" + validBpm);
mp.setVolume(left, right);
}
public void onStartTrackingTouch(SeekBar seekBar)
{
left=left+20;
right=right+20;
mp.setVolume(left, right);
}
public void onStopTrackingTouch(SeekBar seekBar) {
left=left-20;
right=right-20;
mp.setVolume(left, right);
}
});
Looks like a simple fix although your original questions verbiage is really difficult to understand.
You're trying to use your own formula to set the volume and it doesn't look like those 2 methods are a good place to do it. Those two methods should only fire once, since they are only a startTouch or finishTouch.
You need to be using the "progress" integer provided from the onProgressChanged method to set the volume to the mediaplayer accordingly. This integer is the value of where the user set the seekBar.

Categories

Resources