aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorAnanya Sen2012-03-06 17:01:39 -0800
committerAnanya Sen2012-03-06 17:01:39 -0800
commit9e4ee2470726e3334eb47d904a6f4079d4ed7aef (patch)
tree3638893a1e8711b23258a3caee79e8a5c03e5d19 /js/document
parentf7641a9b2d6f33e73227d2f8398509b54fdc0aa1 (diff)
downloadninja-9e4ee2470726e3334eb47d904a6f4079d4ed7aef.tar.gz
IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 80930af2..d90231e3 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -824,6 +824,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
824 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); 824 this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0);
825 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); 825 this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0);
826 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start 826 this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start
827
828 //pause videos on switching or closing the document, so that the browser does not keep downloading the media data
829 this.pauseVideos();
827 } 830 }
828 }, 831 },
829 832
@@ -852,6 +855,42 @@ exports.HTMLDocument = Montage.create(TextDocument, {
852 855
853 856
854 } 857 }
855 } 858 },
856 //////////////////////////////////////////////////////////////////// 859 ////////////////////////////////////////////////////////////////////
860 /**
861 *pause videos on switching or closing the document, so that the browser does not keep downloading the media data
862 *removeSrc : boolean to remove the src if the video... set only in the close document flow
863 */
864 pauseVideos:{
865 value:function(removeSrc){
866 console.log("$$$ pauseVideos");
867 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
868 for(i=0;i<videosArr.length;i++){
869 if(!videosArr[i].paused){
870 videosArr[i].pause();
871 }
872 console.log("$$$ Paused ", videosArr[i]);
873 if((typeof removeSrc !== "undefined") && (removeSrc === true)){
874 videosArr[i].src = "";
875 console.log("$$$ stopped ");
876 }
877 }
878 }
879 },
880
881 /**
882 * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected
883 *removeSrc : boolean to remove the src if the video... set only in the close document flow
884 */
885 stopVideos:{
886 value:function(){
887 console.log("$$$ stopVideos");
888 var videosArr = this.documentRoot.getElementsByTagName("video"), i=0;
889 for(i=0;i<videosArr.length;i++){
890 videosArr[i].src = "";
891 console.log("$$$ stopped ", videosArr[i]);
892 }
893 }
894 }
895 ////////////////////////////////////////////////////////////////////
857}); \ No newline at end of file 896}); \ No newline at end of file