1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 18:42:35 +01:00

Update comment

Co-authored-by: Tobi <TobiGr@users.noreply.github.com>
This commit is contained in:
Thompson3142 2024-10-24 19:35:39 +02:00
parent 05a87da827
commit ba1e9c8e1b

View File

@ -133,7 +133,7 @@ public class SeekbarPreviewThumbnailHolder {
// Get the bounds where the frame is found // Get the bounds where the frame is found
final int[] bounds = frameset.getFrameBoundsAt(currentPosMs); final int[] bounds = frameset.getFrameBoundsAt(currentPosMs);
generatedDataForUrl.put(currentPosMs, generatedDataForUrl.put(currentPosMs,
createBitmapSupplier(srcBitMap, bounds, frameset)); createBitmapSupplier(srcBitMap, bounds, frameset));
currentPosMs += frameset.getDurationPerFrame(); currentPosMs += frameset.getDurationPerFrame();
pos++; pos++;
@ -168,6 +168,18 @@ public class SeekbarPreviewThumbnailHolder {
return null; return null;
} }
// Under some rare circumstances the YouTube API returns slightly too small storyboards,
// (or not the matching frame width/height)
// This would lead to createBitmap cutting out a bitmap that is out of bounds,
// so we need to adjust the bounds accordingly
if (srcBitMap.getWidth() < bounds[1] + frameset.getFrameWidth()) {
bounds[1] = srcBitMap.getWidth() - frameset.getFrameWidth();
}
if (srcBitMap.getHeight() < bounds[2] + frameset.getFrameHeight()) {
bounds[2] = srcBitMap.getHeight() - frameset.getFrameHeight();
}
// Cut out the corresponding bitmap form the "srcBitMap" // Cut out the corresponding bitmap form the "srcBitMap"
final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2], final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight()); frameset.getFrameWidth(), frameset.getFrameHeight());