blonsky95 / TimeStopperAndroid

0 stars 0 forks source link

Exo player allow zoom to video #20

Closed blonsky95 closed 3 years ago

blonsky95 commented 3 years ago

ok zoom works, just modifying the scale x and y of the playerview.videosurfaceview. Still, needs more work

https://medium.com/quick-code/pinch-to-zoom-with-multi-touch-gestures-in-android-d6392e4bf52d

https://developer.android.com/training/gestures/scale#kotlin

blonsky95 commented 3 years ago

clean and test and we golden

blonsky95 commented 3 years ago

test everything working - but - clean up if neccesary?

when user does motion gestures to pan or to scale, it triggers the tap listener that shows/hide/fragments

so, probably have to use a gestureListener to spot taps - find info

blonsky95 commented 3 years ago

ok so now all the gestures are loggable, test and see which ones I want to enable the hiding showing fragments for

blonsky95 commented 3 years ago

Working! so I got a library called ZoomLayout by Natario (props to him) which allows using a ZoomSurfaceView - it works as a surface view to exoplayer, meaning i need to add the Video controller view component as an extra:

<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00000000">

    <com.otaliastudios.zoom.ZoomSurfaceView
        android:id="@+id/surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:horizontalPanEnabled="true"
        app:verticalPanEnabled="true"
        app:zoomEnabled="true"
        />

    <com.google.android.exoplayer2.ui.PlayerControlView
        android:id="@+id/player_controls"
        app:controller_layout_id="@layout/exo_player_control_view"
        app:show_timeout="0"
        app:show_buffering="never"
        app:time_bar_min_update_interval="5"
        android:layout_gravity="bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</FrameLayout>` 

I can add the zoom and horizontal/vertical panning enabled and it does everything, later I on I add in the code: First I declare the class that will do everything:

inner class MyGestureListener : GestureDetector.SimpleOnGestureListener() {

    override fun onSingleTapUp(e: MotionEvent?): Boolean {
        Timber.d( "GESTURE - se ha tocado una vez: ")
        val show =
            (supportFragmentManager.findFragmentById(id.actionBtns_frag) as ActionButtonsFragment).isHidden
        showActionFragments(show)

        if (!isFullScreenActive) {
            setUpFullScreen()
        }
        return true
    }
}`

Here I can choose to only override the gestures I'm interested in by getting a SimpleOnGesturelistiner. To integrate the class in my code I did

mDetector = GestureDetectorCompat(this, MyGestureListener()) surface_view.setOnTouchListener { _, p1 -> mDetector.onTouchEvent(p1) }

where:

private lateinit var mDetector: GestureDetectorCompat