fix: gifs and videos on the message feed now pause when offscreen, conserving cpu usage

This commit is contained in:
Paul Frazee 2015-09-30 12:39:39 -05:00
parent dfddc05330
commit f929c75311
3 changed files with 21 additions and 14 deletions

View File

@ -31,35 +31,36 @@
"tape": "~3.0.0" "tape": "~3.0.0"
}, },
"dependencies": { "dependencies": {
"multiblob": "^1.5.0",
"multicb": "^1.1.0",
"muxrpc": "^6.1.1",
"pull-ipc": "0.0.1",
"pull-pushable": "^1.1.4",
"pull-stream": "^2.27.0",
"scuttlebot": "~7.3.0",
"ssb-config": "^1.0.3",
"ssb-keys": "^4.0.3",
"stream-to-pull-stream": "^1.6.1",
"blob-to-buffer": "^1.2.3", "blob-to-buffer": "^1.2.3",
"emoji-named-characters": "^1.0.1", "emoji-named-characters": "^1.0.1",
"hyperscript": "~1.4.6", "hyperscript": "~1.4.6",
"mime-types": "^2.1.3", "mime-types": "^2.1.3",
"multiblob": "^1.5.0",
"multicb": "^1.1.0",
"muxrpc": "^6.1.1",
"nicedate": "~0.0.0", "nicedate": "~0.0.0",
"observable": "^2.1.3", "observable": "^2.1.3",
"once": "~1.3.1", "once": "~1.3.1",
"pause-offscreen": "^1.0.0",
"phoenix-router": "~1.0.0", "phoenix-router": "~1.0.0",
"published-working-tree": "~0.0.0", "published-working-tree": "~0.0.0",
"pull-cat": "^1.1.7", "pull-cat": "^1.1.7",
"pull-ipc": "0.0.1",
"pull-level": "~1.2.0",
"pull-merge": "~1.0.2", "pull-merge": "~1.0.2",
"pull-notify": "0.0.0",
"pull-paramap": "^1.1.3", "pull-paramap": "^1.1.3",
"pull-pushable": "^1.1.4",
"pull-stream": "^2.27.0",
"pull-stream-to-stream": "~1.3.0", "pull-stream-to-stream": "~1.3.0",
"scuttlebot": "~7.3.0",
"ssb-config": "^1.0.3",
"ssb-keys": "^4.0.3",
"ssb-marked": "~0.5.0", "ssb-marked": "~0.5.0",
"ssb-msg-schemas": "~5.0.0", "ssb-msg-schemas": "~5.0.0",
"ssb-msgs": "~5.0.0", "ssb-msgs": "~5.0.0",
"ssb-ref": "~2.2.0", "ssb-ref": "~2.2.0",
"suggest-box": "~1.1.6", "stream-to-pull-stream": "^1.6.1",
"pull-level": "~1.2.0", "suggest-box": "~1.1.6"
"pull-notify": "0.0.0"
} }
} }

View File

@ -3,10 +3,12 @@ var h = require('hyperscript')
var mlib = require('ssb-msgs') var mlib = require('ssb-msgs')
var pull = require('pull-stream') var pull = require('pull-stream')
var multicb = require('multicb') var multicb = require('multicb')
var pauser = require('pause-offscreen')
var app = require('../app') var app = require('../app')
var com = require('../com') var com = require('../com')
var u = require('../util') var u = require('../util')
module.exports = function (opts) { module.exports = function (opts) {
opts = opts || {} opts = opts || {}
var botcursor var botcursor
@ -36,6 +38,10 @@ module.exports = function (opts) {
fetchBottom(function (n) { fetchBottom(function (n) {
if (opts.onempty && n === 0) if (opts.onempty && n === 0)
opts.onempty(feedEl) opts.onempty(feedEl)
// add offscreen pausing
var unlistenPauser = pauser(containerEl)
ui.onTeardown(unlistenPauser)
}) })
function fetchBottom (cb) { function fetchBottom (cb) {

View File

@ -72,7 +72,7 @@ renderer.image = function (href, title, text) {
href = href.replace(/^&/, '&') href = href.replace(/^&/, '&')
if (ssbref.isLink(href)) { if (ssbref.isLink(href)) {
if ((''+text).indexOf('.webm') >= 0) { if ((''+text).indexOf('.webm') >= 0) {
var out = '<video autoplay=1 loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"' var out = '<video loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"'
if (title) { if (title) {
out += ' title="' + title + '"' out += ' title="' + title + '"'
} }