AfarsheziF
Lurker
Hellow all. after two dayes of tryings I'll try my luck here:
I'm trying to make an app with a moving magnifier on a video background. The video should be static while the magnifier moves freely on the screen and magnify the selected position.
As for now I use this code found here to magnify the video: http://stackoverflow.com/a/21726295/5351001
Then tried to use SurfaceView or TextureView with MediaPlayer to preview the video as background and paint on it - until now with no success.
The code for now:
mtTextureView = (TextureView) findViewById(R.id.textureView);
mtTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener({
@override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Surface s = new Surface(surface);
try {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(uri.toString());
mMediaPlayer.setSurface(s);
mMediaPlayer.prepare();
mMediaPlayer.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return false;
}
@override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
});
mtTextureView.setOnTouchListener(new View.OnTouchListener() {
@override
public boolean onTouch(View v, MotionEvent event) {
Canvas canvas = mtTextureView.lockCanvas();
Paint paint = new Paint();
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
float x = 50;
float y = 50;
float radius = 20;
canvas.drawCircle(x, y, radius, paint);
mtTextureView.unlockCanvasAndPost(canvas);
return false;
}
});
Please help. actually i do not know where to go next.
Suggestions to butter ways to do it will be most welcome Thanks again! OR
I'm trying to make an app with a moving magnifier on a video background. The video should be static while the magnifier moves freely on the screen and magnify the selected position.
As for now I use this code found here to magnify the video: http://stackoverflow.com/a/21726295/5351001
Then tried to use SurfaceView or TextureView with MediaPlayer to preview the video as background and paint on it - until now with no success.
The code for now:
mtTextureView = (TextureView) findViewById(R.id.textureView);
mtTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener({
@override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Surface s = new Surface(surface);
try {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(uri.toString());
mMediaPlayer.setSurface(s);
mMediaPlayer.prepare();
mMediaPlayer.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return false;
}
@override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
});
mtTextureView.setOnTouchListener(new View.OnTouchListener() {
@override
public boolean onTouch(View v, MotionEvent event) {
Canvas canvas = mtTextureView.lockCanvas();
Paint paint = new Paint();
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
float x = 50;
float y = 50;
float radius = 20;
canvas.drawCircle(x, y, radius, paint);
mtTextureView.unlockCanvasAndPost(canvas);
return false;
}
});
Please help. actually i do not know where to go next.
Suggestions to butter ways to do it will be most welcome Thanks again! OR