Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: FlatIO/embed-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8a99be2656fa87002065443487ab2d5abf653edb
Choose a base ref
...
head repository: FlatIO/embed-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d2b5f8aa341b30d1b66a1bcdd2ca6ee119ad1d0c
Choose a head ref

Commits on Dec 27, 2017

  1. Copy the full SHA
    fea26ff View commit details

Commits on Jan 27, 2018

  1. Copy the full SHA
    52cdf02 View commit details
  2. Copy the full SHA
    ab9524b View commit details

Commits on Feb 26, 2018

  1. Copy the full SHA
    cd2e7e6 View commit details

Commits on Mar 6, 2018

  1. doc: fix typo

    gierschv committed Mar 6, 2018
    Copy the full SHA
    46c8453 View commit details

Commits on Jun 3, 2018

  1. Copy the full SHA
    7e18d73 View commit details
  2. Copy the full SHA
    aeec1e9 View commit details

Commits on Oct 23, 2018

  1. Copy the full SHA
    238ebee View commit details
  2. Copy the full SHA
    f899bb0 View commit details
  3. doc: remove bower

    gierschv committed Oct 23, 2018
    Copy the full SHA
    98c7887 View commit details
  4. doc: update readme screen

    gierschv committed Oct 23, 2018
    Copy the full SHA
    fdb5859 View commit details
  5. Copy the full SHA
    18e43ac View commit details
  6. chore: bump version

    gierschv committed Oct 23, 2018
    Copy the full SHA
    255917b View commit details
  7. chore: new build for 0.10.0

    gierschv committed Oct 23, 2018
    Copy the full SHA
    d13f170 View commit details
  8. Copy the full SHA
    08b6fcb View commit details
  9. doc: changelog for 0.10.0

    gierschv committed Oct 23, 2018
    Copy the full SHA
    32b9fbc View commit details

Commits on Nov 9, 2018

  1. Copy the full SHA
    975ed87 View commit details

Commits on Nov 29, 2018

  1. feat: add getMIDI

    gierschv committed Nov 29, 2018
    Copy the full SHA
    42c1678 View commit details
  2. Copy the full SHA
    8a7021d View commit details
  3. Copy the full SHA
    02d5151 View commit details
  4. Copy the full SHA
    d747028 View commit details
  5. chore: changelog 0.11.0

    gierschv committed Nov 29, 2018
    Copy the full SHA
    e4daaff View commit details
  6. docs(readme): 0.11.0

    gierschv committed Nov 29, 2018
    Copy the full SHA
    d2b5f8a View commit details
Showing with 844 additions and 977 deletions.
  1. +13 −0 CHANGELOG.md
  2. +23 −78 README.md
  3. +632 −648 dist/embed.js
  4. +1 −1 dist/embed.js.map
  5. +2 −2 dist/embed.min.js
  6. +1 −1 dist/embed.min.js.map
  7. +2 −2 karma.conf.js
  8. +17 −16 package.json
  9. +12 −20 src/embed.js
  10. +3 −0 src/lib/callback.js
  11. +1 −1 src/lib/embed.js
  12. +130 −201 test/integration/embed-integration.js
  13. +7 −7 test/unit/embed.js
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.11.0

* Add `getMIDI` update
* Update `getMusicXML` to support new returned Uint8Array format (no more `.data`, response is at top level)
* Update cursor: `voiceIdx` is now `voiceIdxInStaff`

## v0.10.0

* Update for the embed release
* Use new CDN endpoint `flat-embed.com` by default
* Remove deprecated `edit` action & event
* Remove `setNoteColor` method

## v0.9.0

* Add method: `mute`
101 changes: 23 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,37 +3,35 @@
[![Build Status](https://travis-ci.org/FlatIO/embed-client.svg?branch=master)](https://travis-ci.org/FlatIO/embed-client)
[![Greenkeeper badge](https://badges.greenkeeper.io/FlatIO/embed-client.svg?token=cd336afca22e743db5a44a2820f0e220d5e54a95530d1f03cc417ea5f0fbf8f0)](https://greenkeeper.io/)
[![NPM Version](https://img.shields.io/npm/v/flat-embed.svg?style=flat)](https://www.npmjs.org/package/flat-embed)
![Bower Version](https://img.shields.io/bower/v/flat-embed.svg?style=flat)

[![Flat's Sheet Music Embed](https://cloud.githubusercontent.com/assets/396537/25476654/26c46c40-2b3b-11e7-9966-1516196ca89b.png)](https://flat.io/developers/embed)
[![Flat's Sheet Music Embed](https://user-images.githubusercontent.com/396537/47357635-99aeb600-d6c7-11e8-9ea0-441eaa2d4908.png)](https://flat.io/developers/embed)

Use this JavaScript Client to interact and receive events from our [Sheet Music Embed](https://flat.io/developers/embed).

If you have any feedback or questions regarding this product, [please feel free to contact our developers support](mailto:developers@flat.io).

## Installation

You can install our Embed Client using [npm](https://www.npmjs.com/package/flat-embed), [yarn](https://yarnpkg.com/en/package/flat-embed) or bower:
You can install our Embed Client using [npm](https://www.npmjs.com/package/flat-embed) or [yarn](https://yarnpkg.com/en/package/flat-embed):

```bash
npm install flat-embed
yarn add flat-embed
bower install flat-embed
```

or use the latest version hosted on jsDelivr:

```html
<script src="https://cdn.jsdelivr.net/npm/flat-embed@v0.8.0/dist/embed.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flat-embed@v0.11.0/dist/embed.min.js"></script>
```

## Getting Started

The simplest way to get started is the pass a DOM element to our embed that will be used as container. By default, this one will completely fit its container:
The simplest way to get started is to pass a DOM element to our embed that will be used as container. By default, this one will completely fit its container:

```html
<div id="embed-container"></div>
<script src="https://cdn.jsdelivr.net/npm/flat-embed@v0.8.0/dist/embed.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flat-embed@v0.11.0/dist/embed.min.js"></script>
<script>
var container = document.getElementById('embed-container');
var embed = new Flat.Embed(container, {
@@ -90,6 +88,7 @@ When instantiating `Flat.Embed`, you can pass options in the second parameter. I
* [`getMusicXML`](#getmusicxmloptions-object-promisestringuint8array-error): Get the score in MusicXML (compressed or not)
* [`getJSON`](#getjson-object): Get the score data in Flat JSON format
* [`getPNG`](#getpngoptions-object-promisestringuint8array-error): Get the score as a PNG file
* [`getMIDI`](#getmidi-promiseuint8array-error): Get the score as a MIDI file
* [`getScoreMeta`](#getscoremeta-object): Get the metadata from the current score (for hosted scores)
* [`fullscreen`](#fullscreenstate-bool-promisevoid-error): Toggle fullscreen mode
* [`play`](#play-promisevoid-error): Start playback
@@ -102,23 +101,19 @@ When instantiating `Flat.Embed`, you can pass options in the second parameter. I
* [`getAutoZoom`](#getautozoom-promiseboolean-error): Get the state of the auto-zoom mode
* [`setAutoZoom`](#setautozoomboolean-promiseboolean-error): Enable or disable the auto-zoom mode
* [`focusScore`](#focusscore-promisevoid-error): Set the focus to the score
* [`setNoteColor`](#setnotecolornotelocation-object-color-string-promiseobject-error): Set the color for the given note
* [`getCursorPosition`](#getcursorposition-promiseobject-error): Get the current cursor position of the score
* [`setCursorPosition`](#setcursorpositionposition-object-promiseobject-error): Set a new position for the cursor
* [Editor Methods](#editor-methods)
* [`setEditorConfig`](#seteditorconfigconfig-object-promiseobject-error): Set the config of the editor
* [`edit`](#editoperations-object-promisevoid-error): Make a modification to the document
* [Events API](#events-api)
* [`scoreLoaded`](#event-scoreLoaded): A new score has been loaded
* [`cursorPosition`](#event-cursorposition): The cursor position changed
* [`rangeSelection`](#event-rangeSelection): The range selected changed
* [`fullscreen`](#event-fullscreen): The fullscreen state changed
* [`print`](#event-print): The score was printed
* [`play`](#event-play): The score playback started
* [`pause`](#event-pause): The score playback paused
* [`stop`](#event-stop): The score playback stopped
* [`playbackPosition`](#event-playbackposition): The playback slider position changed
* [`edit`](#event-edit): An edition has been made to the document

## Viewer Methods

@@ -301,6 +296,17 @@ embed.getPNG({result: 'dataURL'}).then(function (png) {
});
```

### `getMIDI(): Promise<Uint8Array, Error>`

Get the current displayed score as a MIDI file

```js
embed.getMIDI().then(function (midi) {
// MIDI file as a Uint8Array
console.log(midi);
});
```

### `getScoreMeta(): object`

Get the score metadata of the hosted score. The object will have the same format that the one returned [by our API `GET /v2/scores/{score}`](https://flat.io/developers/api/reference/#operation/getScore).
@@ -433,22 +439,6 @@ embed.focusScore().then(function () {
});
```

### `setNoteColor(noteLocation: object, color: string): Promise(<object, Error>)`

Set the color of the note at the location `noteLocation` (on a specific note).

```js
embed.setNoteColor({
"partIdx": 0,
"voiceIdx": 0,
"measureIdx": 2,
"noteIdx": 1,
"line": 2.5
}, 'red').then(function () {
// Note is now red
});
```

### `getCursorPosition(): Promise(<object, Error>)`

Return the current position of the cursor (on a specific note).
@@ -458,7 +448,7 @@ embed.getCursorPosition().then(function (position) {
// position: {
// "partIdx": 0,
// "staffIdx": 1,
// "voiceIdx": 0,
// "voiceIdxInStaff": 0,
// "measureIdx": 2,
// "noteIdx": 1
// }
@@ -480,7 +470,7 @@ embed.setCursorPosition({
// position: {
// "partIdx": 0,
// "staffIdx": 1,
// "voiceIdx": 0,
// "voiceIdxInStaff": 0,
// "measureIdx": 2,
// "noteIdx": 1
// }
@@ -495,43 +485,24 @@ You can enable the editor mode by setting the `mode` to `edit` when creating the
var embed = new Flat.Embed(container, {
embedParams: {
appId: '<your-app-id>',
modeL 'edit'
mode: 'edit'
}
});
```

### `setEditorConfig(config: object): Promise<object, Error>`

**NOTE: "Modes" are now deprecated and new options will be available for this method in the upcoming weeks. [Please contact our team](mailto:developers@flat.io) if you are interested in customizing the embed editor.**

Set a new config for the editor (e.g. the different tools available in the embed). This one will be used at the next loading score.

```js
// For example: hide the Articulation mode, and only display the durations tools in the Note mode
embed.setEditorConfig({
noteMode: {
durations: true
},
articulationMode: false,
defaultMode: 'note'
}).then(function (config) {
embed.setEditorConfig({}).then(function (config) {
// The config of the embed
console.log(config);
});
```

### `edit(operations: object): Promise<void, Error>`

Process some edit operations using one of our internal editing method. Feel free to [contact our developers support](mailto:developers@flat.io) to get more information about the operations available.

```js
embed.edit([
{ name: 'action.SetTitle', opts: { title: 'I <3 Flat'} }
]).then(function () {
// The actions have been executed
}).catch(function (error) {
// Error while executing the actions
});
```

## Events API

Events are broadcasted following actions made by the end user or you with the JavaScript API. You can subscribe to an event using the method [`on`](#onevent-string-callback-function-void), and unsubscribe using [`off`](#onevent-string-callback-function-void). When an event includes some data, this data will be available in the first parameter of the listener callback.
@@ -581,10 +552,6 @@ This event is triggered when a range of notes is selected or the selection chang

This event is triggered when the state of the fullscreen changed. The callback will take a boolean as the first parameter that will be `true` if the fullscreen mode is enabled, and `false` is the display is back to normal (fullscreen exited).

### Event: `print`

This event is triggered when you or the end-user prints the score. This event doesn't include any data.

### Event: `play`

This event is triggered when you or the end-user starts the playback. This event doesn't include any data.
@@ -610,25 +577,3 @@ This event is triggered when the playback slider moves. It is usually triggered
"timePerMeasure": 2
}
```

### Event: `edit`

This event is triggered when one or multiple modifications ave been made to the document. This one will contain a list of operations made:

```json
[
{
"name": "action.SetTempo",
"opts": {
"startMeasureIdx": 0,
"stopMeasureIdx": 1,
"tempo": {
"bpm": 142,
"qpm": 142,
"durationType": 3,
"nbDots": 0
}
}
}
]
```
Loading