├── .gitignore
├── .vscode
├── extensions.json
└── settings.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── dist
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── apple-touch-icon.png
├── assets
│ ├── index.525b4f4f.css
│ ├── index.db294cdd.js
│ ├── index.db294cdd.js.map
│ └── peaks-logo.72e98b64.svg
├── browserconfig.xml
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
├── index.html
├── manifest.json
├── mstile-150x150.png
├── safari-pinned-tab.svg
├── site.webmanifest
├── src
│ ├── App.vue.d.ts
│ ├── components
│ │ ├── AudioPeaks.vue.d.ts
│ │ ├── AudioPeaksWidget.vue.d.ts
│ │ └── __tests__
│ │ │ └── Credits.spec.d.ts
│ ├── documentation
│ │ ├── AccessingThePeaksInstance.vue.d.ts
│ │ ├── AvailableProperties.vue.d.ts
│ │ ├── Credits.vue.d.ts
│ │ ├── DemoWidget.vue.d.ts
│ │ ├── ExampleErrorHandling.vue.d.ts
│ │ ├── ExampleUsingPeaksOptions.vue.d.ts
│ │ ├── ExampleUsingReactivity.vue.d.ts
│ │ ├── ExampleUsingSlots.vue.d.ts
│ │ ├── ExampleUsingVideo.vue.d.ts
│ │ ├── ExampleWithStyle.vue.d.ts
│ │ ├── ExampleWithTheBasics.vue.d.ts
│ │ └── Introduction.vue.d.ts
│ ├── index.d.ts
│ └── main.d.ts
└── vite.config.d.ts
├── env.d.ts
├── index.html
├── package-lock.json
├── package.json
├── public
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── apple-touch-icon.png
├── browserconfig.xml
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
├── mstile-150x150.png
├── safari-pinned-tab.svg
└── site.webmanifest
├── src
├── App.vue
├── assets
│ ├── peaks-logo.svg
│ └── vue-peaks-mods.css
├── components
│ ├── AudioPeaks.vue
│ ├── AudioPeaksWidget.vue
│ └── __tests__
│ │ └── Credits.spec.ts
├── documentation
│ ├── AccessingThePeaksInstance.vue
│ ├── AvailableProperties.vue
│ ├── Credits.vue
│ ├── DemoWidget.vue
│ ├── ExampleErrorHandling.vue
│ ├── ExampleUsingPeaksOptions.vue
│ ├── ExampleUsingReactivity.vue
│ ├── ExampleUsingSlots.vue
│ ├── ExampleUsingVideo.vue
│ ├── ExampleWithStyle.vue
│ ├── ExampleWithTheBasics.vue
│ └── Introduction.vue
├── index.ts
└── main.ts
├── tsconfig.json
├── vite.config.ts
├── vue-peaks-example-ui.png
└── vue-peaks.code-workspace
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output is included
82 | # .nuxt
83 | # dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
106 | # All distribution
107 | dist/
108 |
109 | # Log files
110 | vite.config.ts.timestamp*.mjs
111 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "vue.vscode-typescript-vue-plugin",
4 | "Vue.volar"
5 | ]
6 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.tabSize": 2,
3 | "typescript.preferences.quoteStyle": "single",
4 | "javascript.preferences.quoteStyle": "single",
5 | "prettier.singleQuote": true
6 | }
7 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # vue-peaks
2 |
3 | ## 2.0.2 (2023/10/07)
4 |
5 | - used media links from lib.replayer.app
6 | - removed packed media files (reduces package size)
7 |
8 | ## 2.0.1 (2023/09/17)
9 |
10 | - Added default error display
11 | - Updated documentation
12 |
13 | ## 2.0.0 (2023/09/16)
14 |
15 | - Added (unfinished) Typescript support
16 | - Updated documentation
17 |
18 | ## 2.0.0-beta.5 (2023/09/09)
19 |
20 | - Added library mode
21 | - Included default styles in NPM package
22 |
23 | ## 2.0.0-beta.4 (2023/09/09)
24 |
25 | - Used the new peaks.js version 3
26 | - Added automatic size handling, emulating earlier versions
27 | - Adapted access from the deprecated options (views, colors etc...) to their new model
28 | - Added a default lazy loading for the waveforms
29 | - Added a default progress indicator
30 | - Added video support
31 | - Updated the documentation
32 | - Updated internal handling
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-peaks
2 |
3 | 
4 | 
5 | 
6 | 
7 | 
8 | [](https://www.jsdelivr.com/package/npm/vue-peaks)
9 | [](https://openbase.com/js/vue-peaks?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
10 |
11 | A lightweight Vue wrapper around the [bbc/peaks.js](https://github.com/bbc/peaks.js) audio waveform UI component.
12 |
13 | 
14 |
15 | vue-peaks aims to simplify the use of [peaks.js](https://github.com/bbc/peaks.js/) in a [Vue3](https://vuejs.org/) environment. It provides a single component, `AudioPeaks`.
16 |
17 | Explore the [live examples](https://suterma.github.io/vue-peaks/).
18 |
19 | # Installation
20 |
21 | ```sh
22 | npm install vue-peaks --save
23 | ```
24 |
25 | Installing vue-peaks also installs [peaks.js (version 3)](https://github.com/bbc/peaks.js/) as a dependency. Additionally, peaks.js uses [Konva (version 8 or 9)](https://konvajs.org/) and [waveform-data (version 4)](https://github.com/bbc/waveform-data.js) as peer dependencies; these will get installed with vue-peaks, if not already available.
26 |
27 | # How to use
28 |
29 | ## Basic examples
30 |
31 | vue-peaks provides three modes of operation:
32 |
33 | - **Simple mode**: just set the media URL, and all views are automatically rendered by default
34 | - **Slot mode**: the media element and additional views are provided using named slots
35 | - **External mode**: the media element and additional views are referenced by id or HTML element references
36 |
37 | Preferred: Import the compiled component:
38 |
39 | ```
40 | import { AudioPeaks } from 'vue-peaks';
41 | // default styles for the AudioPeaks component
42 | import 'vue-peaks/dist/style.css';
43 | ```
44 |
45 | Note: Even if you do not use the default (or any other) styles, the overview and zoomview panes still do have a small minimum size set.
46 |
47 | Alternative: The package does not currently properly export types, see issue [#17](https://github.com/suterma/vue-peaks/issues/17). To get TypeScript support, you can also directly include the vue component as SFC:
48 |
49 | ```
50 | import AudioPeaks from 'vue-peaks/src/components/AudioPeaks.vue';
51 | // default styles for the AudioPeaks component are already contained in the SFC
52 | ```
53 |
54 | #### Simple mode
55 |
56 | By default, the [AudioPeaks Vue component](https://github.com/suterma/vue-peaks/blob/main/src/components/AudioPeaks.vue) template creates a new audio element, with the given source URL, and both view panes (overview and zoom, which are rendered with a default size) and a controls pane. A new audio context is created and used to compute the waveform.
57 |
58 | ```
59 |
60 | ```
61 |
62 | #### Slot mode
63 |
64 | To provide your own media element, just place it inside the `AudioPeaks` element (a.k.a. the slot). Vue-peaks will use the first media element in the slot. A new audio context is created and used to compute the waveform.
65 |
66 | ```
67 |
68 | You can also add additional HTML content.
69 |
72 |
73 | ```
74 |
75 | #### Using a specified media element ("external" mode)
76 |
77 | If you already have an existing media element, you can reference it by it's (unique) id, or as an HTMLMediaElement object. A new audio context is created and used to compute the waveform.
78 |
79 | There are also properties available for the overview area and the zoom view area.
80 |
81 | ```
82 |
85 |
5 | You might need to access the peaks.js instance to call various functions
6 | on their extensive
7 | API.
8 |
9 |
10 | In the hosting component, get a reference to the AudioPeaks child
11 | component and, for convenience, a directly computed property to the
12 | actual peaks.js instance:
13 |
14 |
15 |
26 |
27 |
28 | Now you can access the instance and it's methods by using the reference,
29 | like in this example:
30 |
31 |
32 |
46 |
47 |
48 | Remember, that the instance is available only after the child has been
49 | mounted and peaks.js has been initialized.
50 |
7 | Vue-peaks offers it's own properties for customization. Plus, you can
8 | configure the underlying peaks.js instance via the options property (of
9 | type PeaksOptions).
10 |
11 |
12 | Read more about each property directly in the
13 | source code comments.
17 |
5 | peaks.js, a client-side JavaScript component to display and interact with audio
10 | waveforms in the browser. (Released under the LGPL-3.0 license, by the
11 | British Broadcasting Corporation and contributors)
12 |
22 | Bulma, the modern CSS framework that just works. (Released under the MIT
27 | License, by Jeremy Thomas)
28 |
29 |
30 | Bulmaswatch, free themes for Bulma. (Released under the MIT License, by Jenil
35 | Gogari)
36 |
37 |
38 | Material Design Icons, the original. Following Google's Material Design guidelines for system
43 | icons. (Icons released under the Apache 2.0 License, by pictogrammers.com)
44 |
45 |
46 |
50 | Jest, a delightful JavaScript Testing Framework. (Released under the MIT
52 | License, by Facebook)
53 |
54 |
55 | Music from the Album "Not For Sale" by Lidija Roos (Released to the
56 | public, by Lidija Roos)
57 |
58 |
59 |
60 | @highlightjs/vue-plugin, provides a highlightjs component for use in your Vue.js 3 applications.
65 | (Released under the BSD-3-Clause license, by the highlight.js team)
66 |
67 |
68 | @rushstack/eslint-patch, a patch that improves how ESLint loads plugins when working in a
73 | monorepo with a reusable toolchain. (Released under the MIT License, by
74 | Microsoft)
75 |
76 |
77 | @types/jsdom, @types/node, the repository for high quality TypeScript type definitions. (Released
82 | under the MIT License, by various contributors)
83 |
84 |
85 | vite, vitest, @vitejs/plugin-vue, next Generation Frontend Tooling. (Released under the MIT License, by
90 | the vite team)
91 |
92 |
93 | eslint, a tool for identifying and reporting on patterns found in
98 | ECMAScript/JavaScript code. (Released under the MIT License, by the eslint
99 | team)
100 |
101 |
102 | jsdom, a pure-JavaScript implementation of many web standards. (Released under
107 | the MIT License, by the jsdom team)
108 |
109 |
110 | npm-run-all, a CLI tool to run multiple npm-scripts in parallel or sequential.
115 | (Released under the MIT License, by Toru Nagashima)
116 |
117 |
118 | prettier, an opinionated Code Formatter. (Released under the MIT License, by the
123 | prettier team)
124 |
125 |
126 | typescript, a language for application-scale JavaScript. (Released under the
131 | Apache-2.0 license, by Microsoft)
132 |
133 |
134 | vue-tsc, high-performance tooling for Vue. (Released under the MIT License, by
139 | Johnson Chu)
140 |
141 |
142 | VueUse, a Collection of essential Vue Composition Utilities (Released under the
147 | MIT License, by the VueUse team)
148 |
149 |
150 | bulma-slider, Bulma's extension to display sliders (Released under the MIT License,
155 | by Wikiki)
156 |
157 |
158 |
159 |
Initial code is taken from
160 |
161 |
162 |
163 | peaks-vue-demo, by Giovanni Candeo (MIT-licensed)
168 |
10 | This is a showcase for a simple media player. It's available with
11 | vue-peaks as ready-made component,
12 | AudioPeaksWidget.vue, which you can use as-is
13 | or adapt to your needs.
14 |
7 | Errors stemming from peaks.js and from the
8 | HTMLMediaElement's error event
12 | (like a wrong URL or non-responding server) are reported using the
13 | @error event. You can then handle the error event
14 | as you see fit. There is a known issue [#18] in simple mode.
15 |
16 |
17 | vue-peaks has simple internal error handling. In case of any error, the
18 | AudioPeaks gets annotated with the
19 | hasError class, causing a default red striped
20 | display on all views, plus the title attribute gets set to the error
21 | message.
22 |
23 |
Wrong URL
24 |
25 |
26 |
27 | For example, a non-existing URL like
28 | https://example.com/missing.mp3
29 | will never load any content.
30 |
31 |
42 |
43 |
44 |
45 |
46 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
CORS issue
57 |
58 |
59 |
60 | To create the waveforms, peaks.js needs access to the media file in
61 | binary form. To allow this, the web server must support
62 | Cross-origin resource sharing (CORS)
65 | for the origin domain your vue-peaks-enabled app is running on.
66 |
67 |
68 | If CORS is not enabled, your media will play as expected, however the
69 | waveform calculation ends in an error, like in the example below:
70 |
71 |
78 |
79 | The reported error message in this case is "XHR failed", although
80 | playback works just fine:
81 |
44 | To fully customize the appearance and behavior, the Peaks.js configuration options can be provided.
46 |
47 |
Note, that you should omit the the
48 | zoomview.container,
49 | overview.container and
50 | mediaElement options, since these are already handled internally, depending on the view mode
51 | (see explanation with the basic examples).
52 |
72 | AudioPeaks currently does not support reactivity for the options. Still, you can use Vue's reactivity on the
73 | component itself. You can for example:
74 |
75 |
76 |
77 |
Conditionally render the component (by using Vue's built-in
78 | v-if directive). This also releases memory used.
79 |
80 |
Replace the media source by setting the src attribute of the audio element. When
81 | you also set the :key property to a new value, the component re-renders. This
82 | is called the key-changing
83 | technique, and is required to trigger an update of the waveform.
84 |
85 |
86 |
87 | Note that media elements with an empty src attribute cause a MediaError.
88 | If this is a concern to you, use the v-if directive
89 | to conditionally only render the element on non-emtpy URL values.
90 |
91 |
92 |
93 |
94 |
103 |
104 | vue-peaks internally handles resizing of the contained overview and zoomview areas. If you, in the "external mode",
105 | have an external zoomview or overview area that are resizing completely independent from the AudioPeaks instance,
106 | please handle their resizing according to the
107 | peaks.js API docs about resizing.
108 |
9 | To provide your own layout, you can also use the
10 | named slots:
11 |
12 |
#overview
13 |
#zoomview
14 |
#audio (default)
15 |
#controls
16 |
17 |
This allows you for example to
18 |
19 |
layout elements differently
20 |
not render (instead of just not show) elements
21 |
have a completely custom media element
22 |
23 | You can use any of the media element modes with named slots. Use $refs to access the
24 | relevant HTML elements.
25 |
You can use a different mode for each slot, thus mixing the "slot" mode with the "external" mode in the same
26 | component instance.
27 |
28 |
29 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Some slot content here.
65 |
66 |
67 |
68 | In this example, the audio control is not shown,
69 | but some custom
70 | buttons instead:
71 |
74 |
77 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | No zoom controls are shown, by providing an empty template
87 | to the named controls slot.
88 |
7 | vue-peaks also supports video, as peaks.js does. These examples expand on
8 | the above examples, with a focus on video content.
9 |
10 |
Simple mode (with video)
11 |
12 |
13 |
14 | By default, the
15 | AudioPeaks Vue component
19 | template creates a new audio element. While this works for the audio
20 | part of video content, you can specify that the used HTML media element
21 | actually is a video element:
22 |
7 | The AudioPeaks component has it's own CSS
8 | class, plus each generated pane (overview, zoomview, audio/video
9 | element, controls) also has a dedicated CSS class which you can select
10 | for your styles. Note however, that you can not style the waveforms
11 | themselves this way.
12 |
13 |
14 | To use the default style also for external or slotted panes, you need to
15 | set the corresponding classes yourself.
16 |
Simple mode: just set the media URL, and all views are automatically rendered by default
9 |
Slot mode: the media element and additional views are provided using named slots
10 |
External mode: the media element and additional views are referenced by id or HTML element references
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Preferred: Import the compiled component:
19 |
23 |
Note: Even if you do not use the default (or any other) styles, the overview and zoomview panes still do have a small minimum size set.
24 |
25 |
26 |
27 |
28 |
Alternative: The package does not currently properly export types, see issue [#17]. To get TypeScript support, you can also directly include the vue component as SFC:
29 |
30 |
32 |
33 |
34 |
35 |
36 |
Simple mode
37 |
38 |
39 |
40 | By default, the
41 | AudioPeaks Vue
42 | component
43 | template creates a new audio element, with the given source URL, and both view panes
44 | (overview and zoom, which are rendered with a default size) and a controls pane. A new audio context is
45 | created and used to compute the waveform.
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
Slot mode
57 |
58 |
59 |
60 | To provide your own media element, just place it inside the AudioPeaks element (a.k.a. the slot). Vue-peaks will
61 | use
62 | the first media element in the slot. A new audio context is created and used to compute the waveform.
63 |
64 |
65 |
66 |
72 |
73 |
74 |
75 |
76 | You can also add additional HTML content.
77 |
80 |
81 |
82 |
83 |
84 |
85 |
External mode
86 |
External media element only
87 |
88 |
89 |
90 | If you already have an existing media element, you can reference it by it's (unique) id, or as an
91 | HTMLMediaElement
92 | object. A new audio context is
93 | created and used to compute the waveform.
94 |
95 |
96 |
97 |
104 |
105 |
106 |
107 |
110 |
111 | Using the external media element above.
112 |
113 |
114 |
115 |
116 |
117 |
Having all elements externally
118 |
119 |
120 |
121 | There are also properties available for an external overview area and an external zoom view area.
122 |
123 |
124 | Note however, that the default styles and the progress indication are not applied to any external HTML elements.
125 |
126 |
127 |
128 |
144 |
145 |
146 |
147 |
External overview
148 |
External zoomview
149 |
152 |
153 | Using the external overview, zoomview and audio element above.
37 | Installing vue-peaks also installs
38 | peaks.js (version 3)
43 | as a dependency. Additionally, peaks.js uses
44 | Konva (version 8 or 9)
49 | and
50 | waveform-data (version 4)
55 | as peer dependencies; these will get installed with vue-peaks, if not
56 | already available.
57 |