Giter Site home page Giter Site logo

music-memory's Introduction

music-memory Web Component

This is a web component that allows you to play a memory game with music snippets.

Features

  • ๐ŸŽฒ Random cards order
  • ๐ŸŽต Easy setup via HTML elements
  • ๐Ÿ˜Œ LightDOM for convenient styling

Installation

npm install music-memory

Example

<!-- NPM -->
<script type="module">
	import "music-memory.js";
</script>

<!-- JSDelivr -->
<script type="module">
	import "https://cdn.jsdelivr.net/npm/music-memory/music-memory.js";
</script>

<music-memory>
	<audio
		src="path/to/your/audiofile1.mp3"
		data-range1="0-2000"
		data-range2="2001-4000"
	></audio>
	<audio
		src="path/to/your/audiofile2.mp3"
		data-range1="0-2000"
		data-range2="2001-4000"
	></audio>
</music-memory>

How to play

  1. Click on cards to hear different sections of songs.
  2. Find and match pairs from the same song.
    • Correct pairs turn green and stay disabled.
    • Incorrect pairs reset for another attempt.

Usage

  1. The web component automatically creates two <button> elements for each audio element you provide, one for each range.
  2. The component doesn't provide any styling, so you can style it however you want.
    1. "Flipped" buttons get a disabled attribute,
    2. "Matched" buttons get a matched class.
    3. You can have a look at the demo for example styling.
  3. To make styling easy, the component uses LightDOM, so you can style it with basic CSS.
  4. Button order is randomized on each component load (can be deactivated with no-shuffle attribute on the <music-memory> element).
  5. If there's a match, the audio is played from the beginning of range 1 until the end of range 2.
  6. Set attribute debug on the <music-memory> element to show the audio file + part in the button text.

music-memory's People

Contributors

mariohamann avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.