Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize controls, and related changes/features #42

Merged
merged 67 commits into from
May 22, 2017

Conversation

benwiley4000
Copy link
Owner

@benwiley4000 benwiley4000 commented May 18, 2017

Closes #36.

New features

Overview

  • Audio controls can now be specified in any number or order.
  • Developers can now write their own audio control components with access to information and callbacks passed as props from AudioPlayer.
  • We're tracking much more audio state in AudioPlayer, which is accessible (and controllable where applicable) by control components - including currentTime, volume, muted, duration, loop, playbackRate, and the buffered and played TimeRanges objects.
  • Styles are now separated into several source SCSS sheets, which can be imported for custom CSS bundles if a developer chooses.

New AudioPlayer props

  • controls: An array of strings, or components, or both - strings being keywords matching prebuilt control components, and components being custom control implementations. Each control component is rendered by AudioPlayer and passed the full state, as well as the playlist, whether it's ok to seek (seekUnavailable) and any unknown props passed to the AudioPlayer instance.
  • loadFirstTrackOnPlaylistComplete: A boolean (default true) determining if the first track should be loaded up after the playlist concludes (when cycle is false).
  • pauseOnSeekPreview: A boolean (default false) which will make audio playback stop while the user is dragging to seek a new location in the track.

Note we'll be adding several more props for #40, #53 and #54.

New component exports

Controls

Spun-out components for all the controls already available in 1.x:

  • PlayPauseButton
  • BackSkipButton
  • ForwardSkipButton
  • AudioProgress
  • Spacer (an invisible div for layout)

We'll also be creating new components for #1, #53 and #54.

Helper components

  • ProgressBar - generic range slider component useful for audio seeking, volume change, etc.
  • ProgressBarDisplay - the presentational component composed by ProgressBar - use this if you just want to display progress, not change it.
  • PurePropTypesComponent - a component which can be extended instead of PureComponent, in order to only update for changed props listed in propTypes (or for state changes) - helps avoid unnecessary renders for control components, which receive many props but only use a few on average.

Breaking code changes

API

  • hideBackSkip and hideForwardSkip are gone. The new way to hide controls is the controls prop. E.g. ['playpause', 'progress'], if that's all you want.

CSS and layout

  • Class and Sass variable names are now namespaced to be much less likely to clash with others you might use - this means your existing style overrides will almost definitely break.
  • A handful of styles have become React inline styles where it just "made sense," e.g. the inner bar of the ProgressBarDisplay component. Also, styles which seem anti-modular have been removed (width: 100% is no longer automatically added to the outer element; it must be specified by the developer if desired).
  • All id attributes were removed from DOM elements, so if you were using these in your styles, you'll need to switch to classes.
  • A change in progress bar structure forces us to rely on the CSS pointer-events property which is only supported in Internet Explorer since version 11. Pre-IE11 is about half a percent of internet users, but if you need to support them, you can try composing ProgressBar to build your own custom control.
  • Small changes in DOM structure in a few places to accommodate componentization. Shouldn't affect style overrides much if at all, but something to look out for.

Behavior

Behavior should be mostly consistent - though it's hard to be sure without test coverage 😨 (#35).

  • The one difference is that for now, we no longer stop playback when a user forward skips during the last track in a playlist, and cycle is false. It feels weird to skip to the first track, and then the audio pauses. But that's going to change again (hopefully make a bit more sense) for Update cycle=false behavior #41.

@RageMaster14
Copy link

RageMaster14 commented May 19, 2017

Holy Cow you have been busy @benwiley4000 . I've been out of the country for 2 days and there is a 2.0 release incoming, new changes. I am really happy this project is getting a volume bar and so many other changes. You sir deserve a medal 🥇. I read all the changes and this is going to be a major release indeed!

@benwiley4000 benwiley4000 merged commit bfc3f81 into next May 22, 2017
@benwiley4000
Copy link
Owner Author

The description has been updated to reflect the new features and breaking changes in this branch. There's still a good amount of work to do before a 2.0 alpha is ready, but the bulk of the code changes are here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants