How to rotate a listing using video preview?

I am creating a noob for Android development, and I am trying to implement libstreaming example 3 of a sample project . Everything works fine except that I was unable to change the orientation of the video preview in prtrait. No matter what settings I change, it refuses to rotate and remains in landscape mode. I know that portrait orientation can be achieved because spydroid uses libstreaming and displays in portrait orientation. Any help is appreciated.

My corresponding code is:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //<--Does Nothing // Configures the SessionBuilder mSession = SessionBuilder.getInstance() .setContext(getApplicationContext()) .setAudioEncoder(SessionBuilder.AUDIO_AAC) .setAudioQuality(new AudioQuality(8000, 16000)) .setVideoEncoder(SessionBuilder.VIDEO_H264) .setSurfaceView(mSurfaceView) .setPreviewOrientation(90) //<--Does Nothing .setCallback(this) .build(); 
+6
source share
2 answers

In code example 3, it seems that the orientation is fixed in the manifest. Just leave it blank (not even configured for a portrait)

  <activity android:windowSoftInputMode="stateHidden" android:name="net.majorkernelpanic.example3.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.DeviceDefault.Wallpaper.NoTitleBar"> 

This will allow your activity to change orientation.

To strengthen the orientation, add below the line at the end of onCreate (after the line selectQuality(); )

  mSession.setPreviewOrientation(90); mSession.configure(); 
+5
source

Explore the libstreaming library, then go to:

  • Class VideoStream.java
  • Find the createCamera () method, replace "mCamera.setDisplayOrientation (mOrientation)"; with mCamera.setDisplayOrientation (90);
  • Find updateCamera (), replace "mCamera.setDisplayOrientation (mOrientation)"; with "mCamera.setDisplayOrientation (90);"
+2
source

Source: https://habr.com/ru/post/976647/


All Articles