如何在Android上创建YouTube的双击手势? [英] How to create youtube's double-tap gesture on Android?
问题描述
我在Android上具有exoplayer的应用程序.我已经创建了youtube的双击手势,可以通过动画向前或向后跳10秒!如何在双击时创建具有波纹效果的半圆?
I have application with exoplayer on Android. I have create youtube's double-tap gesture to jump 10 seconds forward or backward with animation! How create this semicircle with ripple effect on double tap?
赞
该怎么做?
推荐答案
我也想实现这种功能,所以我自己写了它以复制" YouTube的行为.几乎一样.您可以在此处找到包含示例应用程序的库: https://github.com/vkay94/DoubleTapPlayerView
I've also wanted to implement such feature, so I wrote it myself to "copy" YouTube's behavior. It's almost the same. You can find the library here including a sample app: https://github.com/vkay94/DoubleTapPlayerView
说明是用README编写的,但是由于Stackoverflow的原理:
The instructions are written in the README, but due to Stackoverflow principals:
0)要求:
- 最低SDK:16(我还不能测试21以下的版本)
- ExoPlayer2库(至少为2.11.7),因为替换后的视图写在ExoPlayer的PlayerView上方)
1)将其包括在gradle中(它托管在jitpack.io上,因此您必须将其添加到存储库中):
1) Include it to your gradle (it's hosted on jitpack.io so you've got to add it to your respositories):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0'
}
2)在XML内添加视图:
<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)在活动中进行设置:
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)
这篇关于如何在Android上创建YouTube的双击手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!