Skip to content

Commit cdac50b

Browse files
authored
Merge pull request #11596 from Thompson3142/fix_scrubbing_seekbar_preview_crash
Fix seekbar crashing on drag with faulty frameset
2 parents 05a87da + 2396154 commit cdac50b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ private Supplier<Bitmap> createBitmapSupplier(final Bitmap srcBitMap,
168168
return null;
169169
}
170170

171+
// Under some rare circumstances the YouTube API returns slightly too small storyboards,
172+
// (or not the matching frame width/height)
173+
// This would lead to createBitmap cutting out a bitmap that is out of bounds,
174+
// so we need to adjust the bounds accordingly
175+
if (srcBitMap.getWidth() < bounds[1] + frameset.getFrameWidth()) {
176+
bounds[1] = srcBitMap.getWidth() - frameset.getFrameWidth();
177+
}
178+
179+
if (srcBitMap.getHeight() < bounds[2] + frameset.getFrameHeight()) {
180+
bounds[2] = srcBitMap.getHeight() - frameset.getFrameHeight();
181+
}
182+
171183
// Cut out the corresponding bitmap form the "srcBitMap"
172184
final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
173185
frameset.getFrameWidth(), frameset.getFrameHeight());

0 commit comments

Comments
 (0)