-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import com.frostwire.android.R; | ||
import com.frostwire.android.gui.Librarian; | ||
import com.frostwire.android.gui.services.Engine; | ||
import com.frostwire.fmp4.Mp4Demuxer; | ||
import com.frostwire.platform.FileSystem; | ||
import com.frostwire.platform.Platforms; | ||
import com.frostwire.search.youtube.YouTubeCrawledSearchResult; | ||
|
@@ -84,6 +85,9 @@ public final class YouTubeDownload implements DownloadTransfer { | |
private long speedMarkTimestamp; | ||
private long totalReceivedSinceLastSpeedStamp; | ||
|
||
private long demuxerReadCount; | ||
private long demuxerWriteCount; | ||
|
||
YouTubeDownload(TransferManager manager, YouTubeCrawledSearchResult sr) { | ||
this.manager = manager; | ||
this.sr = sr; | ||
|
@@ -166,6 +170,16 @@ public String getStatus() { | |
} | ||
|
||
public int getProgress() { | ||
if (status == STATUS_DEMUXING) { | ||
try { | ||
if (demuxerReadCount > 0) { // in case fmp4 fail | ||
return (int) (demuxerReadCount * 100 / completeFile.length()); | ||
} | ||
} catch (Throwable e) { | ||
// ignore, fall back to old logic | ||
} | ||
} | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gubatron
Collaborator
|
||
if (size > 0) { | ||
return isComplete() ? 100 : (int) ((bytesReceived * 100) / size); | ||
} else { | ||
|
@@ -478,7 +492,13 @@ public void onComplete(HttpClient client) { | |
} else if (downloadType == DownloadType.DEMUX) { | ||
try { | ||
status = STATUS_DEMUXING; | ||
new MP4Muxer().demuxAudio(tempAudio.getAbsolutePath(), completeFile.getAbsolutePath(), buildMetadata()); | ||
new MP4Muxer().demuxAudio(tempAudio.getAbsolutePath(), completeFile.getAbsolutePath(), buildMetadata(), new Mp4Demuxer.DemuxerListener() { | ||
@Override | ||
public void onCount(long readCount, long writeCount) { | ||
demuxerReadCount = readCount; | ||
demuxerWriteCount = writeCount; | ||
} | ||
}); | ||
|
||
if (!completeFile.exists()) { | ||
//error(null); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hmm, so this will reset the progress bar and start to fill it up again right?
how does it feel when you use it?
What I had in mind was keeping the progress bar at 100% (keeping
getProgress()
as in download progress) while just changing the transfer status text to bedemuxing (55%)
I'll give it a try.