From 130cd6d4b99c9db344ec0ab44a54a59d11b31d2f Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 8 Mar 2012 13:29:58 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video Signed-off-by: Ananya Sen --- js/document/html-document.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index b9b68972..23b55e92 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -842,6 +842,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start + + //pause videos on switching or closing the document, so that the browser does not keep downloading the media data + this.pauseVideos(); } }, @@ -870,6 +873,44 @@ exports.HTMLDocument = Montage.create(TextDocument, { } - } + }, //////////////////////////////////////////////////////////////////// + /** + *pause videos on switching or closing the document, so that the browser does not keep downloading the media data + */ + pauseVideos:{ + value:function(){ + var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; + for(i=0;i