我在Android上有exoplayer的应用程序。我已经创建了youtube的双击手势,可以通过动画向前或向后跳10秒!如何在双击上创建具有波纹效果的半圆?

像这样

android - 如何在Android上创建YouTube的双击手势?-LMLPHP

android - 如何在Android上创建YouTube的双击手势?-LMLPHP

这该怎么做?

最佳答案

我也想实现这种功能,所以我自己写了它以“复制” YouTube的行为。几乎一样。您可以在此处找到包含示例应用程序的库:https://github.com/vkay94/DoubleTapPlayerView
这些指令是用README编写的,但是由于Stackoverflow的原理:
0)要求:

  • 最低SDK:16(我尚无法测试21以下的版本)
  • ExoPlayer2库(至少为2.11.7),因为替换后的 View 写在ExoPlayer的PlayerView上方)

    1)将其包括在gradle 中(它托管在jitpack.io上,因此您必须将其添加到存储库中):
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    
    dependencies {
        implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0'
    }
    
    2)在XML内添加 View :
    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <com.github.vkay94.dtpv.DoubleTapPlayerView
            android:id="@+id/playerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
    
            app:dtpv_controller="@+id/youtube_overlay" />
    
        <com.github.vkay94.dtpv.youtube.YouTubeOverlay
            android:id="@+id/youtube_overlay"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible"
    
            app:yt_playerView="@+id/playerView" />
    </FrameLayout>
    
    3)在 Activity 中进行设置:
    youtube_overlay
        .performListener(object : YouTubeOverlay.PerformListener {
            override fun onAnimationStart() {
                // Do UI changes when circle scaling animation starts (e.g. hide controller views)
                youtube_overlay.visibility = View.VISIBLE
            }
    
            override fun onAnimationEnd() {
                // Do UI changes when circle scaling animation starts (e.g. show controller views)
                youtube_overlay.visibility = View.GONE
            }
        })
        // Uncomment this line if you haven't set yt_playerView in XML
        // .playerView(playerView)
    
    // Uncomment this line if you haven't set dtpv_controller in XML
    // playerView.controller(youtube_overlay)
    
    // Call this method whenever the player is released and recreated
    youtube_overlay.player(simpleExoPlayer)
    

  • 07-26 09:36
    查看更多