some fixes

This commit is contained in:
Thomas 2022-05-13 14:11:11 +02:00
parent 1ef0389997
commit 1c6f7858ca
4 changed files with 16 additions and 5 deletions

View File

@ -24,7 +24,6 @@ import static app.fedilab.fedilabtube.helper.Helper.canMakeAction;
import static app.fedilab.fedilabtube.helper.Helper.getAttColor;
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
import static app.fedilab.fedilabtube.helper.Helper.loadAvatar;
import static app.fedilab.fedilabtube.helper.Helper.loadGiF;
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
import android.Manifest;
@ -56,6 +55,7 @@ import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
@ -160,7 +160,6 @@ import app.fedilab.fedilabtube.drawer.MenuAdapter;
import app.fedilab.fedilabtube.drawer.MenuItemAdapter;
import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
import app.fedilab.fedilabtube.helper.HelperInstance;
import app.fedilab.fedilabtube.helper.Theme;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
@ -234,22 +233,25 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override
public void onStreamPrepared(Torrent torrent) {
Log.v(Helper.TAG,"onStreamPrepared: " + torrent);
torrent.startDownload();
}
@Override
public void onStreamStarted(Torrent torrent) {
Log.v(Helper.TAG,"onStreamStarted: " + torrent);
}
@Override
public void onStreamError(Torrent torrent, Exception e) {
Log.v(Helper.TAG,"onStreamError: " + e.getMessage());
e.printStackTrace();
}
@Override
public void onStreamReady(Torrent torrent) {
Log.v(Helper.TAG,"onStreamReady: " + torrent);
if (torrent.getVideoFile() != null) {
for (int i = 0; i < torrent.getFileNames().length; i++) {
torrent.getTorrentHandle().renameFile(i, torrent.getFileNames()[0].replaceAll("[^a-zA-Z0-9/.-]", "_"));
@ -284,6 +286,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override
public void onStreamProgress(Torrent torrent, StreamStatus status) {
Log.v(Helper.TAG,"onStreamProgress: " + torrent);
if (binding != null) {
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
TextView peers_number = controlView.findViewById(R.id.peers_number);
@ -293,6 +296,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override
public void onStreamStopped() {
Log.v(Helper.TAG,"onStreamStopped: ");
}
@ -1278,6 +1282,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
*/
private void stream(VideoData.Video video, String localTorrentUrl, String resolution, boolean autoPlay, long position, Uri subtitles, String lang) {
videoURL = localTorrentUrl == null ? video.getFileUrl(resolution, PeertubeActivity.this) : localTorrentUrl;
Log.v(Helper.TAG,">>>>>>>>videoURL: " + videoURL );
if (subtitles != null) {
subtitlesStr = subtitles.toString();
}

View File

@ -19,6 +19,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import com.google.gson.annotations.SerializedName;
@ -248,6 +249,7 @@ public class VideoData {
}
}
File file = Helper.defaultFile(context, files);
if (file != null) {
if (mode == Helper.VIDEO_MODE_MAGNET) {
if (file.getMagnetUri() != null) {

View File

@ -42,7 +42,7 @@ android {
}
ext {
libtorrentVersion = '1.2.16.0'
libtorrentVersion = '1.2.11.0'
}
// Custom task which downloads the appropriate version of JAR files for jlibtorrent
@ -71,4 +71,5 @@ clean {
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation files('libs/jlibtorrent-1.2.11.0.jar')
}

View File

@ -16,6 +16,8 @@
package com.github.se_bastiaan.torrentstream;
import android.util.Log;
import com.frostwire.jlibtorrent.AlertListener;
import com.frostwire.jlibtorrent.FileStorage;
import com.frostwire.jlibtorrent.Priority;
@ -257,6 +259,7 @@ public class Torrent implements AlertListener {
* from {@code firstPieceIndex} and {@code lastPieceIndex}. Ignore all other pieces.
*/
public void startDownload() {
Log.v("TubeLab","startDownload: " + state);
if (state == State.STREAMING || state == State.STARTING) return;
state = State.STARTING;
@ -296,7 +299,7 @@ public class Torrent implements AlertListener {
torrentStreamReferences.clear();
torrentHandle.resume();
Log.v("TubeLab","onStreamStarted: " );
listener.onStreamStarted(this);
}