mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-05 17:45:49 +01:00
Merge pull request #7 from YTVanced/videoinfo
VideoInformation for copy buttons
This commit is contained in:
commit
a47bdb3a2b
@ -0,0 +1,6 @@
|
||||
package fi.vanced.libraries.youtube.player;
|
||||
|
||||
public class VideoInformation {
|
||||
public static String currentVideoId;
|
||||
public static long lastKnownVideoTime = -1L;
|
||||
}
|
@ -18,6 +18,8 @@ import java.util.Arrays;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
||||
|
||||
@SuppressLint({"LongLogTag"})
|
||||
public class PlayerController {
|
||||
public static final String TAG = "jakubweg.PlayerController";
|
||||
@ -56,6 +58,8 @@ public class PlayerController {
|
||||
return;
|
||||
}
|
||||
|
||||
VideoInformation.currentVideoId = videoId;
|
||||
|
||||
if (!SponsorBlockSettings.isSponsorBlockEnabled) {
|
||||
currentVideoId = null;
|
||||
return;
|
||||
@ -99,6 +103,7 @@ public class PlayerController {
|
||||
setMillisecondMethod.setAccessible(true);
|
||||
|
||||
lastKnownVideoTime = 0;
|
||||
VideoInformation.lastKnownVideoTime = 0;
|
||||
currentVideoLength = 1;
|
||||
currentPlayerController = new WeakReference<>(o);
|
||||
|
||||
@ -191,6 +196,7 @@ public class PlayerController {
|
||||
public static void setCurrentVideoTime(long millis) {
|
||||
if (VERBOSE)
|
||||
Log.v(TAG, "setCurrentVideoTime: current video time: " + millis);
|
||||
VideoInformation.lastKnownVideoTime = millis;
|
||||
if (!SponsorBlockSettings.isSponsorBlockEnabled) return;
|
||||
lastKnownVideoTime = millis;
|
||||
if (millis <= 0) return;
|
||||
@ -217,6 +223,7 @@ public class PlayerController {
|
||||
public void run() {
|
||||
skipSponsorTask = null;
|
||||
lastKnownVideoTime = segment.start + 1;
|
||||
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
||||
new Handler(Looper.getMainLooper()).post(findAndSkipSegmentRunnable);
|
||||
}
|
||||
};
|
||||
@ -263,8 +270,10 @@ public class PlayerController {
|
||||
* Called very high frequency (once every about 100ms), also in background. It sometimes triggers when a video is paused (couple times in the row with the same value)
|
||||
*/
|
||||
public static void setCurrentVideoTimeHighPrecision(final long millis) {
|
||||
if (lastKnownVideoTime > 0)
|
||||
if (lastKnownVideoTime > 0) {
|
||||
lastKnownVideoTime = millis;
|
||||
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
||||
}
|
||||
else
|
||||
setCurrentVideoTime(millis);
|
||||
}
|
||||
@ -431,6 +440,7 @@ public class PlayerController {
|
||||
if (VERBOSE)
|
||||
Log.i(TAG, "Skipping to millis=" + finalMillisecond);
|
||||
lastKnownVideoTime = finalMillisecond;
|
||||
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
||||
setMillisecondMethod.invoke(currentObj, finalMillisecond);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Cannot skip to millisecond", e);
|
||||
|
@ -1,38 +1,24 @@
|
||||
package pl.jakubweg;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
@ -52,7 +38,6 @@ import static pl.jakubweg.PlayerController.getCurrentVideoId;
|
||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
||||
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
|
||||
import static pl.jakubweg.SponsorBlockSettings.sponsorBlockSkipSegmentsUrl;
|
||||
import static pl.jakubweg.StringRef.sf;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
|
||||
@SuppressWarnings({"LongLogTag"})
|
||||
|
Loading…
Reference in New Issue
Block a user