我在 Android 上有 exoplayer 的应用程序。我已经创建了 youtube双击手势用动画向前或向后跳跃 10 秒!如何在双击时创建具有波纹效果的半圆?
像这样
这个怎么做?
我也想实现这样的功能,所以我自己编写了它来“复制”YouTube的行为。几乎是一样的。您可以在此处找到该库,其中包括示例应用程序:https://github.com/vkay94/DoubleTapPlayerView https://github.com/vkay94/DoubleTapPlayerView
这些说明写在自述文件中,但由于 Stackoverflow 原则:
0)要求:
- 最低 SDK:16(我还无法测试低于 21 的版本)
- ExoPlayer2库(至少2.11.7)因为替换的视图写在ExoPlayer的PlayerView上面)
1)将其包含到你的gradle中(它托管在 jitpack.io 上,因此您必须将其添加到您的存储库中):
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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)