parent
999e882af3
commit
b795f4458a
|
|
@ -39,7 +39,7 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
|
|
||||||
// For Testing
|
// For Testing
|
||||||
val shouldShowDebug = false//BuildConfig.DEBUG
|
val shouldShowDebug = true//BuildConfig.DEBUG
|
||||||
llTesting.isVisible = shouldShowDebug
|
llTesting.isVisible = shouldShowDebug
|
||||||
if (shouldShowDebug) {
|
if (shouldShowDebug) {
|
||||||
butCash.setOnClickListener {
|
butCash.setOnClickListener {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationSet
|
import android.view.animation.AnimationSet
|
||||||
import android.view.animation.ScaleAnimation
|
import android.view.animation.ScaleAnimation
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.NonNull
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
||||||
import com.ama.core.architecture.util.AndroidUtil
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
|
@ -28,8 +27,6 @@ import com.gamedog.vididin.youtubestatistic.TickerTimer
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerCallback
|
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.loadOrCueVideo
|
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFramePlayerOptions
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFramePlayerOptions
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
||||||
import com.viddin.videos.free.databinding.VididinappFeatureHomeItemLayoutBinding as ViewBinding
|
import com.viddin.videos.free.databinding.VididinappFeatureHomeItemLayoutBinding as ViewBinding
|
||||||
|
|
@ -192,7 +189,6 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
mPlayer = youTubePlayer
|
mPlayer = youTubePlayer
|
||||||
val playerUiController = MyPlayerControlView(mPlayerView!!)
|
val playerUiController = MyPlayerControlView(mPlayerView!!)
|
||||||
mPlayerView!!.setCustomPlayerUi(playerUiController.rootView)
|
mPlayerView!!.setCustomPlayerUi(playerUiController.rootView)
|
||||||
|
|
||||||
if (mPendingPlay) {
|
if (mPendingPlay) {
|
||||||
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
||||||
} else if (mIsPreloading) {
|
} else if (mIsPreloading) {
|
||||||
|
|
@ -392,7 +388,6 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
|
|
||||||
|
|
||||||
private fun hidePlayIconAnim() {
|
private fun hidePlayIconAnim() {
|
||||||
return
|
|
||||||
if (!binding?.playIcon!!.isVisible) {
|
if (!binding?.playIcon!!.isVisible) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +395,7 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
|
|
||||||
with (binding?.playIcon!!) {
|
with (binding?.playIcon!!) {
|
||||||
val animationSet = AnimationSet(true)
|
val animationSet = AnimationSet(true)
|
||||||
animationSet.duration = 250
|
animationSet.duration = 100
|
||||||
val alphaAnimation = AlphaAnimation(0.6f, 0.3f)
|
val alphaAnimation = AlphaAnimation(0.6f, 0.3f)
|
||||||
val scaleAnimation = ScaleAnimation(
|
val scaleAnimation = ScaleAnimation(
|
||||||
1.0f, 0.5f,
|
1.0f, 0.5f,
|
||||||
|
|
@ -428,12 +423,11 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPlayIconAnim() {
|
private fun showPlayIconAnim() {
|
||||||
return
|
|
||||||
with (binding?.playIcon!!) {
|
with (binding?.playIcon!!) {
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
|
|
||||||
val animationSet = AnimationSet(true)
|
val animationSet = AnimationSet(true)
|
||||||
animationSet.duration = 250
|
animationSet.duration = 100
|
||||||
val alphaAnimation = AlphaAnimation(0.3f, 0.6f)
|
val alphaAnimation = AlphaAnimation(0.3f, 0.6f)
|
||||||
val scaleAnimation = ScaleAnimation(
|
val scaleAnimation = ScaleAnimation(
|
||||||
0.5f, 1.0f,
|
0.5f, 1.0f,
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
|
|
@ -11,7 +11,7 @@ import org.json.JSONObject
|
||||||
class IFramePlayerOptions private constructor(private val playerOptions: JSONObject) {
|
class IFramePlayerOptions private constructor(private val playerOptions: JSONObject) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getDefault(context: Context) = Builder(context).controls(1).build()
|
fun getDefault(context: Context) = Builder(context).controls(0).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|
|
||||||
|
|
@ -37,23 +37,89 @@
|
||||||
var player;
|
var player;
|
||||||
|
|
||||||
var timerId;
|
var timerId;
|
||||||
|
function hideYouTubeUI() {
|
||||||
|
setInterval(() => {
|
||||||
|
const playerIFrame = document.querySelector("iframe");
|
||||||
|
if (!playerIFrame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const frameDoc = playerIFrame.contentDocument || playerIFrame.contentWindow.document;
|
||||||
|
if (!frameDoc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectorsToHide = [
|
||||||
|
'.ytp-chrome-top',
|
||||||
|
'.ytp-chrome-bottom',
|
||||||
|
'.ytp-gradient-top',
|
||||||
|
'.ytp-gradient-bottom',
|
||||||
|
'.ytp-youtube-button',
|
||||||
|
'.ytp-watermark',
|
||||||
|
'.ytp-ce-element',
|
||||||
|
'.ytp-paid-content-overlay',
|
||||||
|
'.ytp-bezel-container',
|
||||||
|
'.ytp-spinner',
|
||||||
|
'.ytp-cards-teaser',
|
||||||
|
'.ytp-cards-button',
|
||||||
|
'.ytp-show-cards-title'
|
||||||
|
];
|
||||||
|
|
||||||
|
selectorsToHide.forEach(selector => {
|
||||||
|
const elements = frameDoc.querySelectorAll(selector);
|
||||||
|
elements.forEach(el => {
|
||||||
|
if (el.style.display !== 'none') {
|
||||||
|
el.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Special handling for pause overlays to avoid black screen issue
|
||||||
|
const pauseOverlays = ['.ytp-pause-overlay', '.ytp-pause-overlay-container'];
|
||||||
|
pauseOverlays.forEach(selector => {
|
||||||
|
const elements = frameDoc.querySelectorAll(selector);
|
||||||
|
elements.forEach(el => {
|
||||||
|
if (el.style.visibility !== 'hidden') {
|
||||||
|
el.style.visibility = 'hidden';
|
||||||
|
el.style.pointerEvents = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (player && typeof player.unloadModule === 'function') {
|
||||||
|
player.unloadModule('captions');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable captions if any
|
||||||
|
const captions = frameDoc.querySelector('.ytp-caption-window-container');
|
||||||
|
if (captions) {
|
||||||
|
captions.style.display = 'none';
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
function onYouTubeIframeAPIReady() {
|
function onYouTubeIframeAPIReady() {
|
||||||
|
|
||||||
YouTubePlayerBridge.sendYouTubeIFrameAPIReady();
|
YouTubePlayerBridge.sendYouTubeIFrameAPIReady();
|
||||||
|
|
||||||
|
var playerVars = <<injectedPlayerVars>>;
|
||||||
|
// Force some player vars to hide UI elements at the API level
|
||||||
|
// but avoid overriding everything to stay compatible
|
||||||
|
playerVars.rel = 0;
|
||||||
|
playerVars.iv_load_policy = 3;
|
||||||
|
playerVars.modestbranding = 1;
|
||||||
|
|
||||||
var youtubePlayerConfig = {
|
var youtubePlayerConfig = {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
events: {
|
events: {
|
||||||
onReady: function(event) { YouTubePlayerBridge.sendReady() },
|
onReady: function(event) { YouTubePlayerBridge.sendReady();hideYouTubeUI(); },
|
||||||
onStateChange: function(event) { sendPlayerStateChange(event.data) },
|
onStateChange: function(event) { sendPlayerStateChange(event.data) },
|
||||||
onPlaybackQualityChange: function(event) { YouTubePlayerBridge.sendPlaybackQualityChange(event.data) },
|
onPlaybackQualityChange: function(event) { YouTubePlayerBridge.sendPlaybackQualityChange(event.data) },
|
||||||
onPlaybackRateChange: function(event) { YouTubePlayerBridge.sendPlaybackRateChange(event.data) },
|
onPlaybackRateChange: function(event) { YouTubePlayerBridge.sendPlaybackRateChange(event.data) },
|
||||||
onError: function(error) { YouTubePlayerBridge.sendError(error.data) },
|
onError: function(error) { YouTubePlayerBridge.sendError(error.data) },
|
||||||
onApiChange: function(event) { YouTubePlayerBridge.sendApiChange() }
|
onApiChange: function(event) { YouTubePlayerBridge.sendApiChange() }
|
||||||
},
|
},
|
||||||
playerVars: <<injectedPlayerVars>>
|
playerVars: playerVars
|
||||||
};
|
};
|
||||||
|
|
||||||
if (<<injectedVideoId>>) {
|
if (<<injectedVideoId>>) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ class DefaultPlayerUiController(
|
||||||
private val youTubePlayer: YouTubePlayer
|
private val youTubePlayer: YouTubePlayer
|
||||||
) : PlayerUiController {
|
) : PlayerUiController {
|
||||||
|
|
||||||
val rootView: View = View.inflate(youTubePlayerView.context, R.layout.ayp_default_player_ui, null)
|
val rootView: View =
|
||||||
|
View.inflate(youTubePlayerView.context, R.layout.ayp_default_player_ui, null)
|
||||||
|
|
||||||
private var youTubePlayerMenu: YouTubePlayerMenu = DefaultYouTubePlayerMenu(
|
private var youTubePlayerMenu: YouTubePlayerMenu = DefaultYouTubePlayerMenu(
|
||||||
youTubePlayerView.context
|
youTubePlayerView.context
|
||||||
|
|
@ -38,7 +39,8 @@ class DefaultPlayerUiController(
|
||||||
private val panel: View = rootView.findViewById(R.id.panel)
|
private val panel: View = rootView.findViewById(R.id.panel)
|
||||||
|
|
||||||
private val controlsContainer: View = rootView.findViewById(R.id.controls_container)
|
private val controlsContainer: View = rootView.findViewById(R.id.controls_container)
|
||||||
private val extraViewsContainer: LinearLayout = rootView.findViewById(R.id.extra_views_container)
|
private val extraViewsContainer: LinearLayout =
|
||||||
|
rootView.findViewById(R.id.extra_views_container)
|
||||||
|
|
||||||
private val videoTitle: TextView = rootView.findViewById(R.id.video_title)
|
private val videoTitle: TextView = rootView.findViewById(R.id.video_title)
|
||||||
private val liveVideoIndicator: TextView = rootView.findViewById(R.id.live_video_indicator)
|
private val liveVideoIndicator: TextView = rootView.findViewById(R.id.live_video_indicator)
|
||||||
|
|
@ -50,9 +52,11 @@ class DefaultPlayerUiController(
|
||||||
private val fullscreenButton: ImageView = rootView.findViewById(R.id.fullscreen_button)
|
private val fullscreenButton: ImageView = rootView.findViewById(R.id.fullscreen_button)
|
||||||
|
|
||||||
private val customActionLeft: ImageView = rootView.findViewById(R.id.custom_action_left_button)
|
private val customActionLeft: ImageView = rootView.findViewById(R.id.custom_action_left_button)
|
||||||
private val customActionRight: ImageView = rootView.findViewById(R.id.custom_action_right_button)
|
private val customActionRight: ImageView =
|
||||||
|
rootView.findViewById(R.id.custom_action_right_button)
|
||||||
|
|
||||||
private val youtubePlayerSeekBar: YouTubePlayerSeekBar = rootView.findViewById(R.id.youtube_player_seekbar)
|
private val youtubePlayerSeekBar: YouTubePlayerSeekBar =
|
||||||
|
rootView.findViewById(R.id.youtube_player_seekbar)
|
||||||
private val fadeControlsContainer: FadeViewHelper = FadeViewHelper(controlsContainer)
|
private val fadeControlsContainer: FadeViewHelper = FadeViewHelper(controlsContainer)
|
||||||
|
|
||||||
private var onFullscreenButtonListener: View.OnClickListener
|
private var onFullscreenButtonListener: View.OnClickListener
|
||||||
|
|
@ -66,11 +70,19 @@ class DefaultPlayerUiController(
|
||||||
private var isMatchParent = false
|
private var isMatchParent = false
|
||||||
|
|
||||||
private val youTubePlayerStateListener = object : AbstractYouTubePlayerListener() {
|
private val youTubePlayerStateListener = object : AbstractYouTubePlayerListener() {
|
||||||
override fun onStateChange(youTubePlayer: YouTubePlayer, state: PlayerConstants.PlayerState) {
|
override fun onStateChange(
|
||||||
|
youTubePlayer: YouTubePlayer,
|
||||||
|
state: PlayerConstants.PlayerState
|
||||||
|
) {
|
||||||
updateState(state)
|
updateState(state)
|
||||||
|
|
||||||
if (state === PlayerConstants.PlayerState.PLAYING || state === PlayerConstants.PlayerState.PAUSED || state === PlayerConstants.PlayerState.VIDEO_CUED) {
|
if (state === PlayerConstants.PlayerState.PLAYING || state === PlayerConstants.PlayerState.PAUSED || state === PlayerConstants.PlayerState.VIDEO_CUED) {
|
||||||
panel.setBackgroundColor(ContextCompat.getColor(panel.context, android.R.color.transparent))
|
panel.setBackgroundColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
panel.context,
|
||||||
|
android.R.color.transparent
|
||||||
|
)
|
||||||
|
)
|
||||||
progressBar.visibility = View.GONE
|
progressBar.visibility = View.GONE
|
||||||
|
|
||||||
if (isPlayPauseButtonEnabled) playPauseButton.visibility = View.VISIBLE
|
if (isPlayPauseButtonEnabled) playPauseButton.visibility = View.VISIBLE
|
||||||
|
|
@ -83,7 +95,8 @@ class DefaultPlayerUiController(
|
||||||
updatePlayPauseButtonIcon(false)
|
updatePlayPauseButtonIcon(false)
|
||||||
|
|
||||||
if (state === PlayerConstants.PlayerState.BUFFERING) {
|
if (state === PlayerConstants.PlayerState.BUFFERING) {
|
||||||
progressBar.visibility = View.VISIBLE
|
// progressBar.visibility = View.VISIBLE
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
panel.setBackgroundColor(
|
panel.setBackgroundColor(
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
panel.context,
|
panel.context,
|
||||||
|
|
@ -133,6 +146,7 @@ class DefaultPlayerUiController(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initClickListeners() {
|
private fun initClickListeners() {
|
||||||
|
fadeControlsContainer.isDisabled = true
|
||||||
youTubePlayer.addListener(youtubePlayerSeekBar)
|
youTubePlayer.addListener(youtubePlayerSeekBar)
|
||||||
youTubePlayer.addListener(fadeControlsContainer)
|
youTubePlayer.addListener(fadeControlsContainer)
|
||||||
youTubePlayer.addListener(youTubePlayerStateListener)
|
youTubePlayer.addListener(youTubePlayerStateListener)
|
||||||
|
|
@ -218,12 +232,14 @@ class DefaultPlayerUiController(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showCurrentTime(show: Boolean): PlayerUiController {
|
override fun showCurrentTime(show: Boolean): PlayerUiController {
|
||||||
youtubePlayerSeekBar.videoCurrentTimeTextView.visibility = if (show) View.VISIBLE else View.GONE
|
youtubePlayerSeekBar.videoCurrentTimeTextView.visibility =
|
||||||
|
if (show) View.VISIBLE else View.GONE
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showDuration(show: Boolean): PlayerUiController {
|
override fun showDuration(show: Boolean): PlayerUiController {
|
||||||
youtubePlayerSeekBar.videoDurationTextView.visibility = if (show) View.VISIBLE else View.GONE
|
youtubePlayerSeekBar.videoDurationTextView.visibility =
|
||||||
|
if (show) View.VISIBLE else View.GONE
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|
@ -93,6 +94,7 @@
|
||||||
android:id="@+id/progress"
|
android:id="@+id/progress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue