Skip to content

Commit 4cdd9fe

Browse files
committed
Registered only binary files for musicxml
Signed-off-by: Benjamin Giesinger <[email protected]>
1 parent 2a0dfbc commit 4cdd9fe

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

src/components/Sheetmusic.vue

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,65 @@ import Vue from 'vue'
33
import AsyncComputed from 'vue-async-computed'
44
import { OpenSheetMusicDisplay } from 'opensheetmusicdisplay'
55
import logger from '../services/logger.js'
6+
import parsePath from 'path-parse'
67
78
Vue.use(AsyncComputed)
89
910
export 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: 100vh;
5366
}
5467
</style>

src/models/sheetmusic.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ export default {
99
id: 'sheetmusic',
1010
group: 'media',
1111
mimes: [
12+
// These are the official mime types but nextcloud has no proper mechanism to
13+
// update existing files to match them
1214
'application/vnd.recordare.musicxml',
1315
'application/vnd.recordare.musicxml+xml',
14-
'application/xml'
16+
// this registers a binary file for the sheet viewer.
17+
// The Viewer itself checks if it can make sense of it
18+
'application/octet-stream',
1519
],
1620
component: Sheetmusic,
1721
}

0 commit comments

Comments
 (0)