Skip to content

Commit 10ac803

Browse files
Update MainActivity.java
1 parent d3a44ee commit 10ac803

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

app/src/main/java/com/google/android/youtube/pro/MainActivity.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Con
9595
web.loadUrl("javascript:(function(){"+"setTimeout( () => {"+"document.getElementById('player-container-id').style.position='fixed';"+"document.getElementById('player-container-id').style.top='48px'; "+"document.getElementsByClassName('mobile-topbar-header')[0].style.display='flex'; "+"},50);})()");
9696
}
9797
}
98+
@Override
99+
protected void onUserLeaveHint() {
100+
super.onUserLeaveHint();
101+
web.loadUrl("javascript:PIPlayer();");
102+
}
98103

99104

100105

@@ -159,18 +164,16 @@ public void onHideCustomView() {
159164

160165
}
161166

162-
private void downloadFile(String filename, String url, String userAgent) {
167+
private void downloadFile(String filename, String url, String mtype) {
163168
try {
164-
String cookie = CookieManager.getInstance().getCookie(url);
165169
DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
166170
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
167171
request.setTitle(filename)
168-
.setDescription("Downloading...")
169-
.addRequestHeader("cookie", cookie)
170-
.addRequestHeader("User-Agent", userAgent)
171-
.setMimeType("video/mp4")
172+
.setDescription(filename)
173+
.setMimeType(mtype)
172174
.setAllowedOverMetered(true)
173175
.setAllowedOverRoaming(true)
176+
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS.toString(), filename)
174177
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE |
175178
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
176179
downloadManager.enqueue(request);
@@ -207,8 +210,8 @@ public void gohome(String fko) {
207210
}
208211

209212
@JavascriptInterface
210-
public void downvid(String namee,String urll, String uaa) {
211-
downloadFile(namee,urll,uaa);
213+
public void downvid(String namee,String urll, String m) {
214+
downloadFile(namee,urll,m);
212215
}
213216
@JavascriptInterface
214217
public void oplink(String urll) {

0 commit comments

Comments
 (0)