Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add music visualiser #2043

Merged
merged 4 commits into from
Aug 9, 2023
Merged

Add music visualiser #2043

merged 4 commits into from
Aug 9, 2023

Conversation

flip-dots
Copy link
Contributor

This adds a music visualiser option when you fullscreen the music player which looks cool as heck.

Since the discussion I have changed the colours, decreased the number of bars, and increased the smoothing value and sample size to make it look better on 60hz monitors. I still recommend playing around with the parameters though.

Link to discussion

Example Screenshot:

Screenshot 2023-06-09 203255

Also sorry about accidentally closing the previous pull request, I clicked the sync fork button, which didn't do what I thought it would and in trying to fix it I made it even worse by reverting to a previous branch and deleting the old one which closed the pull request. I'm still quite rubbish at this git stuff.

Link to previous pull request

@jellyfin-bot jellyfin-bot added the vue Pull requests that edit or add Vue files label Jun 10, 2023
@flip-dots flip-dots mentioned this pull request Jun 10, 2023
Copy link
Member

@ferferga ferferga left a comment

Choose a reason for hiding this comment

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

Besides the individual comments:

  • There are some code smells reported by SonarCloud. Although checks are failing in master, run npm run typecheck and npm run lint to verify there are no new errors
  • Rename all instances of visualiser to visualizer.

<div ref="musicVisualiser" />
</template>

<script lang="ts">
Copy link
Member

Choose a reason for hiding this comment

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

Use composition API with script setup like we do everywhere else.
With Composition API you don't need the undefined either, since the full script section is garbage collected when the component is unmounted.

export default {
mounted(): void {
visualiser = new AudioMotionAnalyzer(this.$refs.musicVisualiser, {
source: mediaElementRef._value,
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't exist. Do you have the recommended extensions installed in VSCode? This error should appear to you straightaway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Studio code did not show any errors on my end so I checked the recommended extensions and only some of them auto installed. I installed them manually and it started showing some errors, it's fixed now (hopefully).

frontend/src/components/Playback/MusicVisualiser.vue Outdated Show resolved Hide resolved
frontend/src/components/Playback/MusicVisualiser.vue Outdated Show resolved Hide resolved
Comment on lines 177 to 185
<script lang="ts">
export default {
data(): object {
return {
isVisualising: false
};
}
};
</script>
Copy link
Member

Choose a reason for hiding this comment

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

Why???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know that variable refs could be defined like this const isVisualizing = ref(false); until I looked at the composition API docs.

@flip-dots
Copy link
Contributor Author

Besides the individual comments:

* There are some code smells reported by SonarCloud. Although checks are failing in master, run `npm run typecheck` and `npm run lint` to verify there are no new errors

* Rename all instances of `visualiser` to `visualizer`.

Damn, I was kind of hoping I was going to get away with using British English :P

Comment on lines 35 to 41
if (mediaElementRef.value) {
const audioCtx = new AudioContext();

audioCtx
.createMediaElementSource(mediaElementRef.value)
.connect(audioCtx.destination);
}
Copy link
Member

@ferferga ferferga Jun 12, 2023

Choose a reason for hiding this comment

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

I guess we need this at mount to connect to the visualizer instead of onBeforeUnmount? Why this on unmount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you instantiate the visualizer it looks like it inserts itself between the audio source and the speakers automatically (which is why it's not in onMount), so when you disconnect the inputs and outputs it also ends up disconnecting the speakers. So I added those lines to reconnect the audio source directly to the speakers when you disable the visualizer.

@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Jun 19, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jun 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jellyfin-bot jellyfin-bot removed the merge conflict Something has merge conflicts label Jun 28, 2023
@flip-dots flip-dots requested a review from ferferga June 28, 2023 15:28
@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Jul 12, 2023
@jellyfin-bot jellyfin-bot removed the merge conflict Something has merge conflicts label Aug 9, 2023
@sonarcloud
Copy link

sonarcloud bot commented Aug 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ferferga ferferga merged commit 832911e into jellyfin:master Aug 9, 2023
9 of 17 checks passed
@jellyfin-bot
Copy link

Cloudflare Pages deployment

Latest commit 74bc9c6
Status ❌ Failure. Check workflow logs for details
Preview URL Not available
Type 🔀 Preview

View build logs
View bot logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue Pull requests that edit or add Vue files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants