@@ -3,52 +3,65 @@ import Vue from 'vue'
33import AsyncComputed from ' vue-async-computed'
44import { OpenSheetMusicDisplay } from ' opensheetmusicdisplay'
55import logger from ' ../services/logger.js'
6+ import parsePath from ' path-parse'
67
78Vue .use (AsyncComputed )
89
910export default {
1011 name: ' Sheetmusic' ,
1112
12- components: {
13- },
1413 computed: {
15- },
16-
17- asyncComputed: {
18- async url(): Promise <string > {
19- if (this .fallback ) {
20- return preloadMedia (this .filename )
21- } else {
22- return this .src
23- }
14+ name() {
15+ return parsePath (this .basename ).name
2416 },
17+ ext() {
18+ return parsePath (this .basename ).ext
19+ },
20+ isMusicXml() {
21+ return (this .ext === ' .mxl' || this .ext === ' .musicxml' );
22+ }
2523 },
2624 mounted() {
27- const openSheetMusicDisplay = new OpenSheetMusicDisplay (this .$refs .canvas , {
28- autoResize: true ,
29- darkMode: true
30- });
31- const _this = this ;
32- openSheetMusicDisplay .load (this .src )
33- .then (function () {
34- openSheetMusicDisplay .render ()
35- openSheetMusicDisplay .setPageFormat (" A4_P" )
36- _this .doneLoading ()
37- })
38- }
25+ if (this .isMusicXml ) {
26+ const openSheetMusicDisplay = new OpenSheetMusicDisplay (this .$refs .canvas , {
27+ autoResize: true ,
28+ darkMode: true
29+ });
30+ const _this = this ;
31+
32+ logger .debug (' Opening music xml file' , { filename: this .filename })
33+ openSheetMusicDisplay .load (this .src )
34+ .then (() => {
35+ logger .debug (' Loading complete' , {test: this })
36+ openSheetMusicDisplay .render ();
37+ _this .doneLoading ();
38+ })
39+ } else {
40+ this .doneLoading ();
41+ this .OCA .Viewer .close ();
42+ }
43+
44+ },
45+
46+ beforeDestroy() {
47+ // Force stop any ongoing request
48+ logger .debug (' Closing file stream' , { filename: this .filename })
49+ },
3950}
4051
4152
4253
4354 </script >
4455
4556<template >
46- <div class =" sheet-container" ref =" canvas" ></div >
57+ <div v-if =" isMusicXml" >
58+ <div class =" sheet-container" ref =" canvas" ></div >
59+ </div >
4760</template >
4861
4962<style scoped lang="scss">
5063.sheet-container {
5164 width : 85vw ;
52- height : 100 % ;
65+ height : 100 vh ;
5366}
5467 </style >
0 commit comments