Skip to content

Commit

Permalink
Merge pull request #11596 from Thompson3142/fix_scrubbing_seekbar_pre…
Browse files Browse the repository at this point in the history
…view_crash

Fix seekbar crashing on drag with faulty frameset
  • Loading branch information
TobiGr authored Oct 27, 2024
2 parents 05a87da + 2396154 commit cdac50b
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ private Supplier<Bitmap> createBitmapSupplier(final Bitmap srcBitMap,
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"
final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight());
Expand Down

0 comments on commit cdac50b

Please sign in to comment.