Members
(protected) artist :string
Music book artist.
Type:
- string
- Source:
(protected) currentPid :integer
Current page ID (zero-based).
Type:
- integer
- Source:
(protected) pages :Array.<Object>
Array of pages.
Type:
- Array.<Object>
- Source:
(protected) title :string
Music book title.
Type:
- string
- Source:
(protected) tocPid :integer
TOC page ID (zero-based).
Type:
- integer
- Source:
Methods
(static) addAudioPage(props)
Adds a new audio page to the MusicBookPlayer. If a TOC page exists, the
method will update the TOC.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object | Page properties
Properties
|
- Source:
- See:
-
- Footnotes
1) If omitted, the title of the previous page will be copied if a previous page exists. Otherwise, the method will throw an exception.
2) If omitted, the book's artist name will be used.
3) absolute or relative tomediaBaseURI
, see methodcreate()
4) Mandatory for tracks, omit for parts! Method will throw an exception if theaudio
property is missing creating a track page. Track audio URLs must be unique throughout the music book!
5) Mandatory for all parts in a sequence of parts except the first one, omit for tracks! Method will throw an exception of theptoffs
property is missing creating the 2nd, 3rd, etc. part of a track.
- Footnotes
Returns:
The newly created page
(static) addTocPage()
Adds a table-of-contents page displaying a hyperlinked list of pages. If a
TOC page is already existing, the method does nothing.
Note: The TOC will be automatically updated on every invocation of the
Note: The TOC will be automatically updated on every invocation of the
addAudioPage()
method.
- Source:
Returns:
The newly created or existing contents page
(static) create(props)
Creates the MusicBookPlayer singleton. If the object already exists, the
method will just return it. If the singleton does not yet exist, the method
creates it and writes the MusicBookPlayer HTML page and the music book
title page into the current document.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object | Music book properties
Properties
|
- Source:
Returns:
The singleton. The object is also stored in
MusicBookPlayer.instance
and can later be retrieved by
MusicBookPlayer.getInstance()
.
(protected, static) getCssRule(selectorText)
Retrieves a rule from the MediaBookPlayer CSS file.
NOTE: This method is prone to throwing CSS cross-origin access errors and should not be used.
NOTE: This method is prone to throwing CSS cross-origin access errors and should not be used.
Parameters:
Name | Type | Description |
---|---|---|
selectorText |
string | The selector text FIXME: Not robust; must match CSS rule definition exactly! |
- Source:
Returns:
The rule object or
null
if the rule was not found
(static) getFolderURL(baseURL, resource)
Gets the absolute URL of an HTML resource folder.
Parameters:
Name | Type | Description |
---|---|---|
baseURL |
string | Base URL |
resource |
string | Absolute or relative resource path. If the path
name ends with '.html' or '.htm' , the
entire HTML file name will be removed to obtain the folder URL which
contains the file. |
- Source:
Returns:
The absolute URL as described above
(static) getInstance()
Returns the MusicBookPlayer singleton instance. Throws an exception if no
such instance exists.
- Source:
(protected, static) handleScrollEvent()
Content division element scroll event hander.
- Source:
(protected, static) normalizeURL(baseURL, resource)
Normalizes a resource's URL.
Parameters:
Name | Type | Description |
---|---|---|
baseURL |
string | Base URL |
resource |
string | Absolute or relative resource path |
- Source:
Returns:
resource
if the committed value is a full URL, or the
concatenation of baseURL
and resource
if the committed value of resource
was relative
(protected) detectCurrentPage()
Detects the page from the current source and time index of the audio player
element.
- Source:
Returns:
The One-based page number, 0 for the cover page, or -1 in case
of errors.
(protected) editHtmlBody()
Loads the HTML body template and writes it to the current document.
- Source:
(protected) editHtmlHead(title, artist)
Creates the title tag inner text.
Parameters:
Name | Type | Description |
---|---|---|
title |
string | Music book title |
artist |
string | Music book artist |
- Source:
(protected) enableCntsButton(state)
Enables or disables the contents button.
Parameters:
Name | Type | Description |
---|---|---|
state |
boolean | New state, true for enabled,
false for disabled. |
- Source:
(protected) enableNextButton(state)
Enables or disables the next part/track button.
Parameters:
Name | Type | Description |
---|---|---|
state |
boolean | New state, true for enabled,
false for disabled. |
- Source:
(protected) enablePlayButton(state)
Enables or disables the play button.
Parameters:
Name | Type | Description |
---|---|---|
state |
boolean | New state, true for enabled,
false for disabled. |
- Source:
(protected) enablePrevButton(state)
Enables or disables the previous part/track button.
Parameters:
Name | Type | Description |
---|---|---|
state |
boolean | New state, true for enabled,
false for disabled. |
- Source:
(protected) fixTogglePlayPauseButton(play)
HACK: Fix toggling of MediaElement's play/pause button.
Parameters:
Name | Type | Description |
---|---|---|
play |
boolean | If true , show "play" icon, otherwise
show "pause" icon. |
- Source:
(protected) goto(pid, play)
Moves to the specified page.
Parameters:
Name | Type | Description |
---|---|---|
pid |
integer | Zero-based index of page, 0 for cover page |
play |
boolean | If true , play page'html audio file, if
false , stop playing, if undefined , retain
playing state. |
- Source:
(protected) gotoToc()
Scrolls to the TOC page (and keeps the current page active).
- Source:
initialize()
Initializes the MusicBookPlayer singleton. The method is to be invoked only
after the underlying MediaElement has been loaded, i.e., in callback
MediaElement.success
.
- Source:
(protected) isCoverPage(arg)
Determines whether an object is the cover page or a page ID identifies the
cover page. A page is the cover page, iff its page index is 0.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | integer | An object or a zero-based page ID. |
- Source:
Returns:
A boolean
(protected) isPage(arg)
Determines whether an object is a page or if a page ID is valid.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | integer | An object or a zero-based page ID. |
- Source:
Returns:
A valid page object or
null
(protected) isPartPage(arg)
Determines whether an object is a part-of-track page or a page ID
identifies such a page. A page is a track page, iff its ptoffs field is
defined.
Note:> The first page of a sequence of parts track is both, a part and
a track page.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | integer | An object or a zero-based page ID. |
- Source:
Returns:
A boolean
(protected) isTocPage(arg)
Determines whether an object is the table-of-contents page or a page ID
identifies that page. A page is the TOC page, iff its page index equals the
value of
MusicBookPlayer.tocPid
.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | integer | An object or a zero-based page ID. |
- Source:
Returns:
A boolean
(protected) isTrackPage(arg)
Determines whether an object is a track page or a page ID identifies a
track page. A page is a track page, iff it has a predecessor and its audio
file is different from the audio file of the predecessor.
Note:> The first page of a sequence of parts track is both, a part and a track page.
Note:> The first page of a sequence of parts track is both, a part and a track page.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | integer | An object or a zero-based page ID. |
- Source:
Returns:
A boolean
(protected) makeToc()
Creates HTML code of the table of contents page.
- Source:
(protected) next(play)
Moves to the next page if any.
Parameters:
Name | Type | Description |
---|---|---|
play |
boolean | If true , play page's audio file, if
false , stop playing, if undefined , retain
playing state. |
- Source:
(protected) pageIdFromScrollPos()
Retrieves the page ID for the current scroll position of the content
division element.
- Source:
(protected) prev(play)
Moves to the previous page if any.
Parameters:
Name | Type | Description |
---|---|---|
play |
boolean | If true , play page's audio file, if
false , stop playing, if undefined , retain
playing state. |
- Source:
(protected) scrollTo(pid, immediateopt)
Scrolls the contents area to a given page.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pid |
integer | Zero-based index of page, 0 for cover page | ||
immediate |
boolean |
<optional> |
false | If true , skip scroll
animation |
- Source:
(protected) showCredits(visibleopt)
Shows or hides the credits pseudo window.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
visible |
boolean |
<optional> |
true | New visibility state of credits |
- Source:
(protected) tocGoto(pid, play)
Moves from the TOC page to another page. If parameter
pid
refers to the current page, just scroll back and do not rewind audio.
Parameters:
Name | Type | Description |
---|---|---|
pid |
integer | Zero-based index of page, 0 for cover page |
play |
boolean | If true , play page's audio file, if
false , stop playing, if undefined , retain
playing state. |
- Source:
(protected) updateUI(forceopt)
Updates the UI.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Force update |
- Source: