Größenänderung Oberfläche anzeigen für Aspekt-Verhältnis ändern, in-video-anzeigen in android
Arbeite ich an einem video-conferencing-Projekts. Meine Grafikkarte wird mit der Oberfläche anzeigen. Nun während eines video-Anruf gibt es eine chance, Aspekt-Verhältnis ändern, die für die eingehenden frames. Also habe ich versucht den folgenden code für die
public void surfaceResize() {
//WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Point size = new Point();
int screenWidth = 0;
//Get the SurfaceView layout parameters
float aspectRatio = (float) recv_frame_width / recv_frame_height;
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
//Get the width of the screen
getWindowManager().getDefaultDisplay().getSize(size);
screenWidth = size.x;
//Set the width of the SurfaceView to the width of the screen
surflp.width = screenWidth;
//Set the height of the SurfaceView to match the aspect ratio of the video
//be sure to cast these as floats otherwise the calculation will likely be 0
surflp.height = (int) ((1 / aspectRatio) * (float)screenWidth);
//Commit the layout parameters
} else {
size.x = size.y = 0;
//Get the width of the screen
getWindowManager().getDefaultDisplay().getSize(size);
int screenHeight = size.y;
//Set the width of the SurfaceView to the width of the screen
surflp.height = screenHeight;
//Set the width of the SurfaceView to match the aspect ratio of the video
//be sure to cast these as floats otherwise the calculation will likely be 0
surflp.width = (int) ( aspectRatio * (float)screenHeight);
//Commit the layout parameters
//code to do for Portrait Mode
}
surflp.addRule(RelativeLayout.CENTER_HORIZONTAL);
surflp.addRule(RelativeLayout.CENTER_VERTICAL);
if(myVideoSurfaceView != null)
myVideoSurfaceView.setLayoutParams(surflp);
System.out.println("Surface resized*****************************************");
}
Alles in Ordnung ist wenn ich diese Funktion aufrufen, am Anfang des Anrufs.
Mein problem ist wenn ich diese Funktion aufrufen, in der zwischen einem Aufruf zum ändern Seitenverhältnis, es kostet zu viel Zeit, um das nächste frame. Manchmal ist die video-klemmt auch.
Ich versucht zu zerstören, und erstellen Sie die Oberfläche mit
myVideoSurface.setVisibility(VIEW.GONE);
Aber die Oberfläche ist nicht immer erstellt.
Ich bin mit Mediacodec für video-Dekodierung, ich werde benachrichtigt wenn es eine Lösung ändern.
Gibt es etwas, was ich mehr tun sollte für die Größe einer surfaceView, wenn bereits video gespielt wird.
Danke für die Hilfe.........................
- Wenn Ihr problem gelöst ist, bitte akzeptieren Sie die Antwort. Also Fragen Sie nicht zeigen, bis in der "offen" - Liste.
- hier ist eine gute Lösung
Du musst angemeldet sein, um einen Kommentar abzugeben.
Hallo versuchen Sie es mit folgenden code: