Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: src/site/samples/video/example/video.dart

Issue 1387723002: Updating the samples page to reflect the examples that have been retired. (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/site/samples/video/example/video.dart
diff --git a/src/site/samples/video/example/video.dart b/src/site/samples/video/example/video.dart
deleted file mode 100644
index f3156512e1454715dc86605a7e5966dfda4df8ca..0000000000000000000000000000000000000000
--- a/src/site/samples/video/example/video.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// This is a port of "HTML5 Video" to Dart.
-// See: http://www.html5rocks.com/en/tutorials/video/basics/
-
-// Note, the sound is very choppy when using dart2js and running on Google
-// Chrome (version 21 or 22). However, the sound is not choppy when running
-// under Dartium (version 23). It's not a bug in this code since the JavaScript
-// code has the same problem.
-// See also: http://code.google.com/p/chromium/issues/detail?id=141747#c15
-
-import 'dart:html';
-
-class VideoExample {
- VideoElement _videoDom;
- CanvasElement _canvasCopy;
- CanvasElement _canvasDraw;
- List<num> _offsets;
- List<num> _inertias;
- CanvasRenderingContext2D _ctxCopy, _ctxDraw;
- bool _animationRunning = false;
-
- final _outPadding = 100;
- final _slices = 4;
-
- VideoExample() {
- var inertia = -2.0;
-
- _videoDom = querySelector('#video-canvas-fancy');
- _canvasCopy = querySelector('#canvas-copy-fancy');
- _canvasDraw = querySelector('#canvas-draw-fancy');
- _offsets = <num>[];
- _inertias = <num>[];
-
- for (var i = 0; i < _slices; i++) {
- _offsets.add(0);
- _inertias.add(inertia);
- inertia += 0.4;
- }
-
- _videoDom.onCanPlay.listen((e) => _onCanPlay());
- _videoDom.onPlay.listen((e) => _onPlay());
- _videoDom.onPause.listen((e) => _stopAnimation());
- _videoDom.onEnded.listen((e) => _stopAnimation());
- }
-
- void _onCanPlay() {
- _canvasCopy.width = _canvasDraw.width = _videoDom.videoWidth;
- _canvasCopy.height = _videoDom.videoHeight;
- _canvasDraw.height = _videoDom.videoHeight + _outPadding;
- _ctxCopy = _canvasCopy.context2D;
- _ctxDraw = _canvasDraw.context2D;
- }
-
- void _onPlay() {
- _animationRunning = true;
- _processEffectFrame();
- }
-
- void _processEffectFrame() {
- if (!_animationRunning) return;
- var sliceWidth = _videoDom.videoWidth / _slices;
- _ctxCopy.drawImage(_videoDom, 0, 0);
- _ctxDraw.clearRect(0, 0, _canvasDraw.width, _canvasDraw.height);
- for (var i = 0; i < _slices; i++) {
- var sx = i * sliceWidth;
- var sy = 0;
- var sw = sliceWidth;
- var sh = _videoDom.videoHeight;
- var dx = sx;
- var dy = _offsets[i] + sy + _outPadding;
- var dw = sw;
- var dh = sh;
- _ctxDraw.drawImageScaledFromSource(_canvasCopy, sx, sy, sw, sh, dx, dy, dw, dh);
- if ((_offsets[i] + _inertias[i]).abs() < _outPadding) {
- _offsets[i] += _inertias[i];
- } else {
- _inertias[i] = -_inertias[i];
- }
- }
- window.requestAnimationFrame((double time) {
- _processEffectFrame();
- return false;
- });
- }
-
- void _stopAnimation() {
- _animationRunning = false;
- }
-}
-
-void main() {
- new VideoExample();
-}
« no previous file with comments | « src/site/samples/video/example/packages/browser/interop.js ('k') | src/site/samples/video/example/video.dart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698