@@ -16,6 +16,7 @@ import android.view.MotionEvent
1616import android.view.View
1717import android.view.View.OnLongClickListener
1818import android.view.ViewGroup
19+ import android.view.animation.DecelerateInterpolator
1920import android.widget.FrameLayout
2021import android.widget.ImageView
2122import android.widget.PopupWindow
@@ -692,8 +693,8 @@ class HJzvdStd @JvmOverloads constructor(
692693 var layoutParams = blockLayoutParams
693694 if (originalContainer is ConstraintLayout ) {
694695 layoutParams = savedConstraintLayoutParams ? : ConstraintLayout .LayoutParams (
695- ViewGroup . LayoutParams .MATCH_PARENT ,
696- ViewGroup . LayoutParams .WRAP_CONTENT
696+ LayoutParams .MATCH_PARENT ,
697+ LayoutParams .WRAP_CONTENT
697698 )
698699 } else if (originalContainer is FrameLayout ) {
699700 layoutParams = LayoutParams (blockLayoutParams)
@@ -733,14 +734,37 @@ class HJzvdStd @JvmOverloads constructor(
733734 CONTAINER_LIST .add(vg)
734735 val decorView = (JZUtils .scanForActivity(jzvdContext)).window.decorView as ViewGroup
735736 val fullLayout = LayoutParams (
736- ViewGroup . LayoutParams .MATCH_PARENT ,
737- ViewGroup . LayoutParams .MATCH_PARENT
737+ LayoutParams .MATCH_PARENT ,
738+ LayoutParams .MATCH_PARENT
738739 )
740+ val mediaKernel = CURRENT_JZVD ?.mediaInterface as ? ExoMediaKernel
741+ val videoWidth = mediaKernel?.videoRealWidth? : 0
742+ val videoHeight = mediaKernel?.videoRealHeight? : 0
743+ val isPortraitVideo = videoWidth > 0 && videoHeight > 0 && videoWidth < videoHeight
744+ if (isPortraitVideo) {
745+ pivotY = 0f
746+ scaleY = 0.5f
747+ }
739748 decorView.addView(this , fullLayout)
749+ if (isPortraitVideo) {
750+ animate()
751+ .scaleY(1f )
752+ .setDuration(300 )
753+ .setInterpolator(DecelerateInterpolator ())
754+ .start()
755+ }
740756 setScreenFullscreen()
741757 JZUtils .hideStatusBar(jzvdContext)
742- if (activity != null ) {
743- manager.lockOrientation(activity,OrientationManager .ScreenOrientation .LANDSCAPE )
758+ val targetOrientation = if (videoWidth > 0 && videoHeight > 0 ) {
759+ if (isPortraitVideo)
760+ OrientationManager .ScreenOrientation .PORTRAIT
761+ else
762+ OrientationManager .ScreenOrientation .LANDSCAPE
763+ } else {
764+ OrientationManager .ScreenOrientation .LANDSCAPE
765+ }
766+ activity?.let {
767+ manager.lockOrientation(it, targetOrientation)
744768 }
745769 JZUtils .hideSystemUI(jzvdContext)
746770 }
0 commit comments