var options = {
//
// Zoomable waveform view options
//
zoomview: {
// Container <div> element for the zoomable waveform view
container: document.getElementById('zoomview-container'),
// Color for the zoomable waveform
// You can also use a 2 stop gradient here. See setWaveformColor()
waveformColor: 'rgba(0, 225, 128, 1)',
// Color for the played region of the zoomable waveform
// You can also use a 2 stop gradient here. See setWaveformColor()
playedWaveformColor: 'rgba(0, 225, 128, 1)',
// Color of the playhead
playheadColor: 'rgba(0, 0, 0, 1)',
// Color of the playhead text
playheadTextColor: '#aaa',
// Background color of the playhead text
playheadBackgroundColor: 'transparent',
// Padding around the playhead text (pixels)
playheadPadding: 2,
// Width of the playhead (pixels)
playheadWidth: 1,
// Tolerance for clicks in the zoomview to be interpreted as
// dragging the playhead (pixels)
playheadClickTolerance: 3,
// Returns a string for the playhead timestamp label
formatPlayheadTime: function,
// Show current time next to the playhead
showPlayheadTime: false,
// Precision of time label of playhead and point/segment markers
timeLabelPrecision: 2,
// Color of the axis gridlines
axisGridlineColor: '#ccc',
// Color of the axis labels
axisLabelColor: '#aaa',
// Returns a string for the axis label timestamps
formatAxisTime: function,
// Show or hide the axis label timestamps
showAxisLabels: true,
// Height of the axis markers at the top of the waveform
axisTopMarkerHeight: 10,
// Height of the axis markers at the top of the waveform
axisBottomMarkerHeight: 10,
// Font family for axis labels, playhead, and point and segment markers
fontFamily: 'sans-serif',
// Font size for axis labels, playhead, and point and segment markers
fontSize: 11,
// Font style for axis labels, playhead, and point and segment markers
// (either 'normal', 'bold', or 'italic')
fontStyle: 'normal',
// Mouse-wheel mode: either 'none' or 'scroll'
wheelMode: 'none',
// Auto-scroll the waveform when the playhead reaches the edge of
// the visible waveform
autoScroll: true,
// The offset in pixels edge of the visible waveform to trigger
// auto-scroll
autoScrollOffset: 100,
// Enables point markers to be shown on the zoomable waveform
enablePoints: true,
// Enables segments to be shown on the zoomable waveform
enableSegments: true,
segmentOptions: {
// Some segment options can be overridden for the zoomable waveform,
// see segmentOptions below
}
},
//
// Overview waveform options
//
overview: {
// Container <div> element for the non-zoomable "overview" waveform
container: document.getElementById('overview-container')
// Color for the overview waveform
// You can also use a 2 stop gradient here. See setWaveformColor()
waveformColor: 'rgba(0,0,0,0.2)',
// Color for the played region of the overview waveform
// You can also use a 2 stop gradient here. See setWaveformColor()
playedWaveformColor: 'rgba(0, 225, 128, 1)',
// Color for the overview waveform rectangle
// that shows what the zoomable view shows
highlightColor: 'grey',
// Stroke color for the zoomed region
highlightStrokeColor: 'transparent',
// Opacity for the zoomed region
highlightOpacity: 0.3,
// Corner Radius for the zoomed region
highlightCornerRadius: 2,
// The default number of pixels from the top and bottom of the canvas
// that the overviewHighlight takes up
highlightOffset: 11,
// Color of the playhead
playheadColor: 'rgba(0, 0, 0, 1)',
// Color of the playhead text
playheadTextColor: '#aaa',
// Background color of the playhead text
playheadBackgroundColor: 'transparent',
// Padding around the playhead text (pixels)
playheadPadding: 2,
// Returns a string for the playhead timestamp label
formatPlayheadTime: function,
// Show current time next to the playhead
showPlayheadTime: false,
// Precision of time label of playhead and point/segment markers
timeLabelPrecision: 2,
// Color of the axis gridlines
axisGridlineColor: '#ccc',
// Color of the axis labels
axisLabelColor: '#aaa',
// Returns a string for the axis label timestamps
formatAxisTime: function,
// Show or hide the axis label timestamps
showAxisLabels: true,
// Height of the axis markers at the top of the waveform
axisTopMarkerHeight: 10,
// Height of the axis markers at the top of the waveform
axisBottomMarkerHeight: 10,
// Font family for axis labels, playhead, and point and segment markers
fontFamily: 'sans-serif',
// Font size for axis labels, playhead, and point and segment markers
fontSize: 11,
// Font style for axis labels, playhead, and point and segment markers
// (either 'normal', 'bold', or 'italic')
fontStyle: 'normal',
// Enables point markers to be shown on the overview waveform
enablePoints: true,
// Enables segments to be shown on the overview waveform
enableSegments: true,
segmentOptions: {
// Some segment options can be overridden for the overview waveform,
// see segmentOptions below
}
},
//
// Scrollbar options
//
scrollbar: {
// Container <div> element for the scrollbar
container: document.getElementById('scrollbar-container'),
// Scrollbar color. The background color can be set using CSS on the
// scrollbar container element
color: '#888888',
// Minimum scrollbar handle width, in pixels
minWidth: 50
}
// HTML media element containing an audio track
mediaElement: document.querySelector('audio'),
//
// Pre-computed waveform data options
//
dataUri: {
// Binary format waveform data URL
arraybuffer: '/data/sample.dat',
// JSON format waveform data URL
json: '/data/sample.json',
},
waveformData: {
// ArrayBuffer containing binary format waveform data
arraybuffer: null,
// Object containing JSON format waveform data
json: null
},
// If true, Peaks.js will send credentials with all network requests,
// i.e., when fetching waveform data
withCredentials: false,
//
// Web Audio generated waveform data options
//
webAudio: {
// A Web Audio AudioContext instance which can be used
// to render the waveform if dataUri is not provided
audioContext: new AudioContext(),
// Alternatively, provide an AudioBuffer containing the decoded audio
// samples. In this case, an AudioContext is not needed
audioBuffer: null,
// If true, the waveform will show all available channels
// If false, the audio is shown as a single channel waveform
multiChannel: false
},
// Array of zoom levels in samples per pixel. Smaller numbers represent
// being more "zoomed in".
zoomLevels: [512, 1024, 2048, 4096],
// To avoid computation when changing zoom level, Peaks.js maintains a cache
// of waveforms at different zoom levels. This is enabled by default, but
// can be disabled by setting waveformCache to false
waveformCache: true
//
// Keyboard input options
//
// Bind keyboard controls
keyboard: false,
// Keyboard nudge increment in seconds (left arrow/right arrow)
nudgeIncrement: 0.01,
//
// Default view options. Each of these can be set independently for each
// waveform view, under the 'zoomview' and 'overview' options
// (described above).
//
// Waveform color
// You can also use a 2 stop gradient here. See setWaveformColor()
waveformColor: 'rgba(0, 225, 128, 1)',
// Color for the played waveform region
// You can also use a 2 stop gradient here. See setWaveformColor()
playedWaveformColor: 'rgba(0, 225, 128, 1)',
// Color of the playhead
playheadColor: 'rgba(0, 0, 0, 1)',
// Color of the playhead text
playheadTextColor: '#aaa',
// Background color of the playhead text
playheadBackgroundColor: 'transparent',
// Padding around the playhead text (pixels)
playheadPadding: 2,
// Color of the axis gridlines
axisGridlineColor: '#ccc',
// Color of the axis labels
axisLabelColor: '#aaa',
// Font family for axis labels, playhead, and point and segment markers
fontFamily: 'sans-serif',
// Font size for axis labels, playhead, and point and segment markers
fontSize: 11,
// Font style for axis labels, playhead, and point and segment markers
// (either 'normal', 'bold', or 'italic')
fontStyle: 'normal',
// Precision of time label of playhead and point/segment markers
timeLabelPrecision: 2,
// Show current time next to the playhead (zoomview only)
showPlayheadTime: false,
//
// Point and segment options
//
// Default point marker color
pointMarkerColor: '#ff0000',
// if true, emit cue events on the Peaks instance (see Cue Events)
emitCueEvents: false,
// Enables point markers to be shown on the waveform views
enablePoints: true,
// Enables segments to be shown on the waveform views
enableSegments: true,
segmentOptions: {
// Enable segment markers
markers: true,
// Enable segment overlays
overlay: false,
// Color for segment start marker handles
startMarkerColor: '#aaaaaa',
// Color for segment end marker handles
endMarkerColor: '#aaaaaa',
// Segment waveform color
waveformColor: '#ff851b',
// Segment overlay color
overlayColor: '#ff0000',
// Segment overlay opacity
overlayOpacity: 0.3,
// Segment overlay border color
overlayBorderColor: '#ff0000',
// Segment overlay border width
overlayBorderWidth: 2,
// Segment overlay border corner radius
overlayCornerRadius: 5,
// Segment overlay offset from the top and bottom of the waveform view, in pixels
overlayOffset: 25,
// Segment overlay label alignment, either 'top-left' or 'center'
overlayLabelAlign: 'top-left',
// Segment overlay label offset, in pixels
overlayLabelPadding: 8,
// Segment overlay label color
overlayLabelColor: '#000000',
// Segment overlay font family
overlayFontFamily: 'sans-serif',
// Segment overlay font size
overlayFontSize: 12,
// Segment overlay font style
overlayFontStyle: 'normal'
},
//
// Customization options (see customizing.md)
//
createSegmentMarker: null,
createSegmentLabel: null,
createPointMarker: null,
player: null,
//
// Point and segment initialization
//
segments: [
{
startTime: 120,
endTime: 140,
editable: true,
color: "#ff0000",
labelText: "My label"
},
{
startTime: 220,
endTime: 240,
editable: false,
color: "#00ff00",
labelText: "My Second label"
}
],
points: [
{
time: 150,
editable: true,
color: "#00ff00",
labelText: "A point"
},
{
time: 160,
editable: true,
color: "#00ff00",
labelText: "Another point"
}
],
//
// Debugging options
//
// Diagnostic or error information is written to this function.
// The default is console.error
logger: console.error.bind(console)
}; 里面是Peaks.js里的option各项配置,请翻一下各自有什么用处
最新发布