testimonials 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec2476402ec7e3a4d2c414cad340aae35a0456db87d65c950d527e983ab7053
4
- data.tar.gz: a910019755bf56f04cdfc180c6706be9a1b6fe2246c481822a647610a63a53f5
3
+ metadata.gz: f32069743e1abbbe0f5ce913e32e0c37f1e23230c0f5d59bb903dd9189761153
4
+ data.tar.gz: fbae328897d5aea39f1896e55324df8182f08bae09e7907a30510dfd3026c82d
5
5
  SHA512:
6
- metadata.gz: 84e12d4988eddabcba1ba473b7ddb92158674f34051fdf7005aae11171962b686621c81aade5121c33a700363422f1843183d6bb4d81c32123e2a84c757c51ee
7
- data.tar.gz: 97731aaeffebf8bad9e02e44005a69d1507c99b46badda66735d3c4d5b756dbcb06eda88e10a3716d36ef13a82d9c3f962ac9993f0c2968e8d2bd39f8443b576
6
+ metadata.gz: c9345c6257864c1531782f4a7cdd1fd136118aab23898e57ae28723b13a27107f657d865b77947c0ac26de7ed06b143ce8cb2ffd0463a6cfc57c08f28cf90085
7
+ data.tar.gz: 27d79110f0b6e043373e0e2989f7f1947810d2c52a1c6e21b5f71e759739c9762f668e6e05f0bbb8a9e9879e38dcb4b61de8d3d276d626a89b1440e4c3af6e35
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.2
4
+
5
+ - Uploaded videos now get a poster frame too (grabbed from the file
6
+ client-side), so Safari shows a preview instead of a black frame before
7
+ play — previously only recorded videos captured a poster. Best-effort;
8
+ legacy videos with no stored poster are unaffected (re-upload to add one).
9
+
3
10
  ## 0.4.1
4
11
 
5
12
  - Video poster frames: a still is captured from the camera at record time and
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Testimonials
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -715,11 +715,35 @@
715
715
  var file = input.files && input.files[0];
716
716
  if (!file) return;
717
717
  state.videoBlob = file;
718
+ // Recorded videos grab their poster from the live preview; uploaded
719
+ // files have no live stream, so grab one from the file itself — else
720
+ // Safari shows a black frame (it won't paint a posterless video).
721
+ capturePosterFromFile(file);
718
722
  showStage(formStage(state.formTitle || config.labels.shareTitle));
719
723
  });
720
724
  input.click();
721
725
  }
722
726
 
727
+ // Load an uploaded video offscreen, seek a hair past the start (frame 0 is
728
+ // often black), and reuse capturePoster's canvas grab. Best-effort and
729
+ // async — if the customer sends before it resolves, no poster, no harm.
730
+ function capturePosterFromFile(file) {
731
+ try {
732
+ var url = URL.createObjectURL(file);
733
+ var probe = document.createElement("video");
734
+ probe.preload = "metadata";
735
+ probe.muted = true;
736
+ probe.playsInline = true;
737
+ var cleanup = function () { try { URL.revokeObjectURL(url); } catch (e) { /* noop */ } };
738
+ probe.addEventListener("loadeddata", function () {
739
+ try { probe.currentTime = Math.min(0.1, (probe.duration || 1) / 2); } catch (e) { cleanup(); }
740
+ });
741
+ probe.addEventListener("seeked", function () { capturePoster(probe); cleanup(); });
742
+ probe.addEventListener("error", cleanup);
743
+ probe.src = url;
744
+ } catch (e) { /* poster is best-effort */ }
745
+ }
746
+
723
747
  function stopMedia() {
724
748
  if (media.timer) clearInterval(media.timer);
725
749
  if (media.recorder && media.recorder.state !== "inactive") {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testimonials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov