diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 41 |
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 |