forked from TeamNewPipe/NewPipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainPlayerUi_Integration_Example.java
More file actions
60 lines (48 loc) · 1.96 KB
/
MainPlayerUi_Integration_Example.java
File metadata and controls
60 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// MainPlayerUi.java Integration Example
// This shows the minimal changes needed to integrate the improved gesture controller
package org.schabi.newpipe.player.ui;
// ... existing imports ...
import org.schabi.newpipe.player.gesture.ImprovedMainPlayerGestureListener;
public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutChangeListener {
// ... existing fields ...
@Override
protected void setupElementsVisibility() {
// ... existing setup code ...
// OLD CODE:
// gestureListener = new MainPlayerGestureListener(this);
// NEW CODE - Replace with improved version:
gestureListener = new ImprovedMainPlayerGestureListener(this);
// ... rest of existing setup code ...
}
@Override
public void destroy() {
// Clean up improved gesture listener
if (gestureListener instanceof ImprovedMainPlayerGestureListener) {
((ImprovedMainPlayerGestureListener) gestureListener).cleanup();
}
// ... existing cleanup code ...
super.destroy();
}
// ... rest of existing MainPlayerUi code remains unchanged ...
}
/*
* INTEGRATION NOTES:
*
* 1. ONLY CHANGE: Replace MainPlayerGestureListener with ImprovedMainPlayerGestureListener
* 2. ADD CLEANUP: Call cleanup() in destroy() method
* 3. NO OTHER CHANGES NEEDED: All existing functionality is preserved
*
* BENEFITS:
* - Eliminates UI loops between control visibility and gestures
* - YouTube-inspired hold-to-2x speed functionality
* - Proper state management prevents conflicts
* - All existing volume/brightness gestures still work
* - Auto-hide controls after 3 seconds like YouTube
*
* TESTING:
* - Single tap: Shows/hides controls (no loops)
* - Long press: Activates 2x speed with visual indicator
* - Controls stay hidden during 2x speed
* - Volume/brightness gestures work normally
* - Scrolling cancels 2x speed appropriately
*/