Skip to content
This repository was archived by the owner on May 7, 2023. It is now read-only.

Not working when torrent has multiple files #16

Description

@jayaram9877

Works pretty well when the torrent has a single video file but never calls onServerReady

void initializeServer(int port, int fileIndex) {
    selectedFileIndex = fileIndex;
    System.out.println("Selecteed index is"+ fileIndex);
    TorrentOptions torrentOptions = new TorrentOptions.Builder()
            .saveLocation(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS))
            .removeFilesAfterStop(true)
           .autoDownload(false)
            .build();

    String ipAddress = "127.0.0.1";
    try {
        ipAddress = getIpAddress();

    } catch (Exception e) {
        e.printStackTrace();
    }

    torrentStreamServer = TorrentStreamServer.getInstance();
    torrentStreamServer.setTorrentOptions(torrentOptions);
    torrentStreamServer.setServerHost(ipAddress);
    torrentStreamServer.setServerPort(8080);
    torrentStreamServer.startTorrentStream();
    torrentStreamServer.addListener(this);

    try {
        torrentStreamServer.startStream(torrentInfo, torrentPath);
    } catch (TorrentStreamNotInitializedException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}
@Override
public void onStreamError(Torrent torrent, Exception e) {
    System.out.println("Stream Error"+ e.toString());

}

@Override
public void onStreamReady(Torrent torrent) {
    System.out.println("Stream ready" );

}

@Override
public void onStreamProgress(Torrent torrent, StreamStatus status) {

    System.out.println("Progress is"+ status.progress +" and current interested byte is"+ torrent.getInterestedPieceIndex());
}

@Override
public void onStreamStopped() {
    System.out.println("Stream stopped");

}

@Override
public void onServerReady(String url) {
    System.out.println("Serving on "+ url);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions