Skip to content

Commit

Permalink
feat: streaming video with external player
Browse files Browse the repository at this point in the history
Co-authored-by: dic1911 <[email protected]>
  • Loading branch information
omg-xtao and dic1911 committed Jan 2, 2025
1 parent b956f46 commit 7888b0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.EnvUtil;
import tw.nekomimi.nekogram.utils.FileUtil;
import tw.nekomimi.nekogram.utils.TelegramUtil;

public class AndroidUtilities {
public final static int LIGHT_STATUS_BAR_OVERLAY = 0x0f000000, DARK_STATUS_BAR_OVERLAY = 0x33000000;
Expand Down Expand Up @@ -4097,6 +4098,18 @@ public static boolean openForView(MessageObject message, Activity activity, Them
if (f == null || !f.exists()) {
f = FileLoader.getInstance(message.currentAccount).getPathToMessage(message.messageOwner);
}
if (f != null && !f.exists()) {
String cacheFilePath = AndroidUtilities.getCacheDir().getAbsolutePath();
cacheFilePath += "/" + TelegramUtil.getFileNameWithoutEx(f.getName());
List<String> suffix = Arrays.asList(".pt", ".temp");
for (int ii = 0; ii < suffix.size(); ii++) {
f = new File(cacheFilePath + suffix.get(ii));
if (f.exists()) {
message.putInDownloadsStore = true;
break;
}
}
}
String mimeType = message.type == MessageObject.TYPE_FILE || message.type == MessageObject.TYPE_TEXT ? message.getMimeType() : null;
return openForView(f, message.getFileName(), mimeType, activity, resourcesProvider, restrict);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class FileLoadOperation {
private boolean forceSmallChunk;
private Runnable fileWriteRunnable;
public boolean isStory;
public boolean isVideo;

public volatile boolean caughtPremiumFloodWait;
public void setStream(FileLoadOperationStream stream, boolean streamPriority, long streamOffset) {
Expand Down Expand Up @@ -438,6 +439,7 @@ public FileLoadOperation(TLRPC.Document documentLocation, Object parent) {
}
}
}
isVideo = (MessageObject.isVideoDocument(documentLocation));
ungzip = "application/x-tgsticker".equals(documentLocation.mime_type) || "application/x-tgwallpattern".equals(documentLocation.mime_type);
totalBytesCount = documentLocation.size;
if (key != null) {
Expand Down Expand Up @@ -780,7 +782,7 @@ protected void removeStreamListener(final FileLoadOperationStream operation) {
}
FileLog.e("FileLoadOperation " + getFileName() + " removing stream listener " + operation);
streamListeners.remove(operation);
if (!isStory && streamListeners.isEmpty()) {
if (!isStory && !isVideo && streamListeners.isEmpty()) {
Utilities.stageQueue.cancelRunnable(cancelAfterNoStreamListeners);
Utilities.stageQueue.postRunnable(cancelAfterNoStreamListeners, 1200);
} else if (!streamListeners.isEmpty()) {
Expand Down

0 comments on commit 7888b0c

Please sign in to comment.