Skip to content

Conversation

bneumann
Copy link

@bneumann bneumann commented Mar 9, 2025

This is a propsal on how to integrate *.mxl and *.musicxml files in the viewer. It fixes #424
It works fairly well although the MIME type is not correct the sheets I tested. My guess is that Nextcloud symply uses application/octed-stream for any unknown binary file. And since the viewer relies on the MIME type I needed to filter on the extnesion as well.
Please let me know if there is a better solution. Other then that, here you have it. Sheet music in your nextcloud :)

bneumann added 3 commits March 9, 2025 21:51
Signed-off-by: Benjamin Giesinger <benjamin.giesinger@pm.me>
Signed-off-by: Benjamin Giesinger <benjamin.giesinger@pm.me>
Signed-off-by: Benjamin Giesinger <benjamin.giesinger@pm.me>
@bneumann bneumann force-pushed the feat/musicXmlViewer branch from 18a7bc6 to 4cdd9fe Compare March 9, 2025 20:52
Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

'application/vnd.recordare.musicxml+xml',
// this registers a binary file for the sheet viewer.
// The Viewer itself checks if it can make sense of it
'application/octet-stream',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be there.
the two mime above should be enough :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, thing is that I have no idea how to persuade Nextcloud to use the application/vnd.recordare.musicxml+xml MIME type for music xml. It always shows as binary. Any suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely!! There is a dedicated mime file on the server repository. It automatically matches an extension with a mime :)
You need to edit it here. Let me search for an example

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah nice. That's what I was looking for. Thought the match is done here. Ok I will submit a request there

<style scoped lang="scss">
.sheet-container {
width: 85vw;
height: 100vh;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100vh is known to cause issues on some mobile devices.
Can you make it reactive instead and make it fit with percentages?

})
} else {
this.doneLoading();
this.OCA.Viewer.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ok from a code design pov.
The Viewer.vue handles the open/close. Not the views :)

But I guess this will be fixed when the application/octet-stream mime issue is handled

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is a stupid workaround and I am not happy about it. Best way for me to handle sheet music would be to check both: Mime type and extension.
Internally Opensheetmusicxml checks the first 4 bytes to distinguish if it is XML or MXL (compressed data).

if (this.isMusicXml) {
const openSheetMusicDisplay = new OpenSheetMusicDisplay(this.$refs.canvas, {
autoResize: true,
darkMode: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/blob/79a356bc9c4c09945456920fdd7b3d2474094886/src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts#L557-L563

Please use the current user settings to decide whether to set dark mode to true or not.

export function isDarkModeEnabled() {
	const darkModePreference = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches
	const darkModeSetting = document.body.getAttribute('data-themes')?.includes('dark')
	return darkModeSetting || darkModePreference || false
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for something like that, where is this method defined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked with dark and light theme and the background of the viewer is always black. So true is kinda correct here. Otherwise I could alter the background of the viewer if that makes sense and is doable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, you're right. I completely forgot!
We do force the dark theme on viewer 😅🙈
Can you then only add a small comment to explain why it's hard coded to true ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, will do :)

@skjnldsv skjnldsv added enhancement New feature or request 2. developing Work in progress file support request Request support for a new mime type labels Mar 25, 2025
@skjnldsv
Copy link
Member

Hey @bneumann, thanks for the PR! I added some comments :)

@bneumann
Copy link
Author

I will continue once nextcloud/server#51703 is merged and I can work with the latest version

@skjnldsv
Copy link
Member

skjnldsv commented Jun 1, 2025

Hey @bneumann, nextcloud/server#51703 is merged and deployed :)
Wanna resume this PR ? 😊

@bneumann
Copy link
Author

bneumann commented Jun 1, 2025

I took a look today into the latest 32 version of nextcloud and tried to get it to start. I failed miserably and gave up just now. I am usually writing web services in C# which is basically one button to push and everything works. But this PHP thing is driving me nuts. Had the apache running. Wrong user permissions. Fixed the permissions. Installation wants again other user permission.
I am waiting until someone creates a working container for version 32 which I can use to just test this Vue component here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress enhancement New feature or request feedback-requested file support request Request support for a new mime type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for MusicXML files

2 participants