Turn audio into a shareable video. forked from nypublicradio/audiogram

video.js 577B

123456789101112131415161718192021222324252627282930313233343536
  1. var d3 = require("d3");
  2. var video = document.querySelector("video");
  3. function kill() {
  4. // Pause the video if it's playing
  5. if (!video.paused && !video.ended && 0 < video.currentTime) {
  6. video.pause();
  7. }
  8. d3.select("body").classed("rendered", false);
  9. }
  10. function update(url, name) {
  11. var filename = (name || "Audiogram") + ".mp4";
  12. d3.select("#download")
  13. .attr("download", filename)
  14. .attr("href", url);
  15. d3.select(video).select("source")
  16. .attr("src", url);
  17. video.load();
  18. video.play();
  19. }
  20. module.exports = {
  21. kill: kill,
  22. update: update
  23. }