Coder Social home page Coder Social logo

samvera-labs / ramp Goto Github PK

View Code? Open in Web Editor NEW
27.0 15.0 5.0 379.54 MB

Interactive, IIIF powered audio/video media player React components library. Styleguidist Docs: https://samvera-labs.github.io/ramp/

Home Page: https://ramp.avalonmediasystem.org/

JavaScript 95.82% SCSS 4.18%
react iiif iiif-presentation-3 styleguidist rollup

ramp's Introduction

@samvera/ramp

Netlify Status CircleCI

Renamed NPM component library previously known as @samvera/iiif-react-media-player

An NPM component library of interactive IIIF Presentation 3.0 API powered audio/video media player ReactJS components.

General Usage:

Add the @samvera/ramp components library from NPM into your ReactJS application via yarn or npm.

yarn add @samvera/ramp

// Add peer dependencies
yarn add [email protected]

NOTE (Ramp <= v3.1.2): [email protected] needs to be used because the included version of @silvermine/videojs-quality-selector is incompatible with Video.js >= v8.0.0.

NOTE (Next release): Ramp will be upgrading to [email protected] in its next release because @silvermine/videojs-quality-selector has been updated. If you are installing Ramp from the Main branch you need to run yarn add [email protected] in your ReactJS application to get the correct peer dependency.

Example usage

import React from 'react';
import { IIIFPlayer, MediaPlayer, StructuredNavigation, Transcript } from "@samvera/ramp";
import 'video.js/dist/video-js.css';

// Import starter styles 
import "@samvera/ramp/dist/ramp.css";

const App = () => {
  // Get your manifest from somewhere
  const manifestUrl = "https://some-manifest-url-here.json";

  // Transcript props
  const props = {
    playerID: 'player-id',
    transcripts: [
      {
        canvasId: 0,
        items: [ { title: "Title", url: "https://some-transcript-url-here.json" } ]
      }
    ]
  }

  return (
    <IIIFPlayer manifestUrl={manifestUrl}>
      <MediaPlayer enableFileDownload={false} />
      <StructuredNavigation />
      <Transcript {...props} />
    </IIIFPlayer>
  );
}

export default App;

Documentation

See the Styleguidist docs for documentation on the components. And the GitHub Wiki for more details on usage and implementation of these components.

Developing

Styleguidist development

Styleguidist, in addition to providing documentation, also offers an isolated development environment. To start the dev environment, run:

yarn dev

To build a static html version of the docs (which Github pages uses), run:

yarn styleguide:build

This will create a set of static documentation HTML files in the project's /styleguide directory. In this documentation, each component is explained with a code sample and a description of its props and functionality.

An example usage of all the components in the library is served from the /demo directory. This showcases the real-time usage of the components in an application. To start this example, run:

yarn demo

Then open up a browser and navigate to http://localhost:3003. It has live reload enabled via webpack, so live updates are immediately rendered in the browser during development.

Deployment

To deploy your forked version of this repo, run:

yarn build

This will create CommoneJS, ES Module, and UMD distribution files located in the /dist/ directory.

Netlify Demo-site Deploy

A demo site is hosted with Netlify.

This demo instance can read a publicly available IIIF Presentation 3.0 Manifest given the URL of the manifest and display content in the manifest.

A new build is triggered and published in Netlify when code changes are merged to the main branch in this repository.

Running the tests

To run the tests, with a full coverage report, run:

yarn test

To run tests in watch mode:

yarn test:watch

Ramp uses Jest and react-testing-library to build its test suite.

Coding style tests

There is a prettierrc file with project coding style settings.

Contributing

If you're working on PR for this project, create a feature branch off of main.

This repository follows the Samvera Community Code of Conduct and language recommendations.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Contributors

See also the list of contributors to see others who participated in this project.

License

The library is available as open source under the terms of the Apache 2.0 License.

Acknowledgments

ramp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ramp's Issues

Update timerail highlight when player keeps on playing

Description

The time-rail highlight which shows structure within the player gets updated when the following events happen;

  • on first render of the player, when there's a media fragment starting from 0
  • on seek/scrubbing player events using the player's time-rail
  • using structure navigation component below the player
  • on timeupdate player event when the media file keeps on playing naturally

Current status: right now the player highlights the time-rail when the first 3 events occur (#62)
Need to update the time-rail highlight as the player keeps on playing, which emits the timeupdate event.

Done Looks Like

The time-rail highlight get updated on all the events mentions above.

Notes

When implementing the callback for timeupdate event from VideoJS was tried, it kept colliding with state updates in the ReactJS application. This made the timeupdate to not be reflected in the player properly.

Make use of the new presentation of captions in IIIF manifests

Description

The player's parser uses seeAlso property which was an intermediate step of with respect to presenting captions/subtitles in manifests.
With the latest cookbook recipe for captions, the parser need to be updated.

Done Looks Like

  • sample manifests are updated to use the latest presentation of captions/subtitles
  • parser recognizes the latest presentation
  • player displays captions/subtitles when provided

Fix failing tests following new pattern for testing the Provider

Description

A number of unit tests are not passing due to all the code overhaul. Make tests work following patterns established in the src/components/StructuredNavigation/StructuredNavigation.test.js component.

Done looks like

  • All current unit tests pass

IIIF Player Release 1.1.0

Description

Publish a new release with the new features and other minor changes made after the last beta release.
Features and fixes to include:

  • Quality selection
  • Audio UI changes
  • Parser update for new caption presentation in IIIF manifests
  • Improved structure navigation within player (with time-rail highlights for media fragments)
  • Better visualization for nested structures

Done Looks Like

  • NPM package for 1.1.0 version published

Provide URL Field on Example/Showcase Page for Testing

Description

In a previous version of the IIIF player, there was a static page built with a field for entering an arbitrary URL for a manifest that would then load in the player. This would be nice to have again in the current repository. The existing page could be repurposed or a new one created.

Done Looks Like

Error in the console when switching between canvases

Description

The player gets updated when navigating across canvases. Sometimes VideoJS tries to access the player before the ReactJS application fully renders it. This spits out an error to the console as follows;

index.js:1 VIDEOJS: ERROR: TypeError: Cannot read property 'currentTime' of null
    at Html5.<computed> [as currentTime] (video.es.js:20673)
    at get (video.es.js:9665)
    at Player.techGet_ (video.es.js:23112)
    at Player.currentTime (video.es.js:23351)
    at onUpdateMarker (videojs-markers-plugin.js:392)
    at Player.onTimeUpdate (videojs-markers-plugin.js:370)
    at HTMLDivElement.data.dispatcher (video.es.js:1901)
    at trigger (video.es.js:2037)
    at Player.trigger$1 [as trigger] (video.es.js:2923)
    at Player.<computed> [as handleTechTimeupdate_] (video.es.js:25911)
    at HTMLAudioElement.data.dispatcher (video.es.js:1901)
console.<computed> @ index.js:1
overrideMethod @ react_devtools_backend.js:2430
(anonymous) @ video.es.js:100
log.error @ video.es.js:288
data.dispatcher @ video.es.js:1903
trigger @ video.es.js:2037
trigger$1 @ video.es.js:2923
Player.<computed> @ video.es.js:25911
data.dispatcher @ video.es.js:1901

This doesn't break the player, but needs to be fixed.

To reproduce this, render the ReactJS component and play the first section, while it's playing click on a structure item in a different section (canvas) in the structure navigation component. This will log the error in the console.

Done Looks Like

When switching between canvases the ReactJS codes handles the VideoJS's access to the player instance properly, so that there are no errors.

Handle transitions between media sources in new project structure

Description

Now that we're not using Redux, we need to handle transitions between media (audio/video) sources with Video.js, as defined in a IIIF manifest. Does it re-render? How do we go from audio player to video player? Etc.

image

Done looks like

  • VideoJS player successfully plays media from different sources when clicking around navigation
  • Transition from audio to video player is handled seamlessly with the player

Transcript Component Wireframing

Description

Developing and defining wireframes for the transcript component.

Done Looks Like

  • Creation and refinement of wireframes during swarm session
  • Created wireframes will be implemented in work on #70

Rollup packaging works

Description

The projects build command should successfully package the 3 starter components, IIIFPlayer, StructuredNavigation, and MediaPlayer

Done looks like

  • Components, IIIFPlayer, StructuredNavigation, and MediaPlayer are packaged successfully
  • Test importing into a local CRA app

Add keyboard shortcuts to player

Description

Most media players nowadays have keyboard shortcuts. The basic ones are as follows;

  • Exit/enter full-screen - f

  • Mute/un-mute - m

  • Play/pause - space-bar

  • Increase/decrease volume - up/down arrow keys

  • Jump forward/backwards in playback - right/left arrow keys

Done Looks Like

The player functions work with the key presses listed above.

Notes

VideoJS plugin that can be used: https://github.com/ctd1500/videojs-hotkeys

Player is not able to play `m3u8` streams

Description

Kevin Price from UT reported: we're delivering the files using .m3u8 through wowza. When it's delivering an .mp4 file, there is no issue. When we're delivering an .mp3 file, it gives us Playback cannot continue. No available working or supported playlists.
This seems to be an outstanding issue with VideoJS: videojs/http-streaming#910

Done Looks Like

  • Investigate the issue and find out whether this can be fixed by handling streaming from within the ReactJS application without relying on VideoJS.
  • If this can be fixed from within the ReactJS application, put in a fix so that the player can handle .m3u8 stream URLs like other types.

Support Captions

Description

When references to caption files for media are included in a manifest, they should be fed to the Captions in a IIIF manifest should be passed along to the media player.

Example: https://github.com/samvera-labs/iiif-react-media-player/blob/main/src/json/test_data/lunchroom-manners.json

  "seeAlso": [
    {
      "id": "https://dlib.indiana.edu/iiif_av/lunchroom_manners/lunchroom_manners.vtt",
      "type": "Text",
      "format": "application/webvtt",
      "label": "subtitles"
    }
  ],

Done Looks Like

  • Caption resource info is retrieved from the manifest and stored
  • The player is initialized with a reference to the caption/subtitle file
  • The captions button appears and can be selected to toggle the visibility of the caption/subtitle

Configure component markdown files to use mock manifest data

Description

We're building out a component library of independent components which can interact together, but also should stand on their own (I think). In a component (like src/components/StructuredNavigation/StructuredNavigation.js) which accepts a prop manifest, we need a way to import a mock manifest and pass it as a prop to the component in the markdown file src/components/StructuredNavigation/Readme.md.

image

Done looks like

  • StructuredNavigation component uses mock data in it's markdown file. This pattern we can extend to future components

Implement support for the "start" property as defined by the IIIF Presentation 3 specs

Description

Often an audio or video resource will have content that is part of the object but not significant, such as a microphone check, or audience noise before the start of a performance, or a test card. The start property allows the publisher to specify a point where a client application should begin playback.

See recipe in the IIIF Cookbook.

Done looks like

  • IIIF player responds to the start property according to specs

Create Playlist component UI

Description

Need to recreate the "Playlists" UI feature from Avalon Media system, into an isolated component in this code repository.

Screenshot of the current playlists look in Avalon:

Screenshot from 2020-11-05 09-49-20

To see playlists in action see this playlist in one of Avalon's test servers.

Done looks like

  • Playlist items UI created

Notes

This depends on how IIIF manifests model playlists.

Wire transcripts with the player

Description

Hook the wireframes implemented in #70 with the other components (player, structure navigation). So that, when media is played transcript is shown in sync with the other components.

Done Looks Like

  • Pass player ID as a prop and see it can be synced
  • Transcript is shown in sync with the player and structure navigation
  • Transcript text can be used (clicked) to seek the player

Notes

This work might be blocked by; the way IIIF manifests annotate transcripts.

Add Lil' scrubber

Description

Add lil' scrub to the iiif-player like we have in the avalon player

The code that makes this work could possibly be pulled from the Avalon Media System player itself...

Screenshot from 2020-03-02 11-02-46.png

Related to #5216. Note that we want to retain the functionality of the detailed scrub, but the design in the UI can be updated.

Done Looks Like

iiif-player has a lil' scrubber

Render nested structure appropriately

Description

Structure navigation doesn't render the nested structures with correct indentation for better visualization of it in the structure navigation component:

Screenshot from 2021-04-16 11-16-42.png

Done Looks Like

Nested structure renders with correct indentation:

Screenshot from 2021-04-16 11-20-15.png

Configure Rollup to bundle all CSS in a separate file

Description

To keep the UI customizable, we'll ship the player and components with a stylesheet that a user can pull in if they wish, allow them to add their own CSS to their React application.

Done looks like

  • Rollup bundles all Sass/CSS separately into a file.
  • Test the import in an outside application, including and not including the styles to verify it works.

Indicate active structured navigation link

Description

As media content plays across navigation links, the links should highlight or provide some kind of visual cue.

image

Done looks like

  • "Active" navigation sections are highlighted (wireframes coming soon)
  • An active class should be placed on the parent <li className="active"> item, to hook the CSS style onto
  • We need to keep track of the currently playing item in the (I think) Manifest context module.

Change UI for Audio Sources

Description

The current UI for the IIIF player when using audio sources isn't as polished as it could be. We'll have a swarm session to look at how it is now and discuss what to change for production use.

Done Looks Like

  • What needs to be changed?
  • What should the final version look like?
  • Are there other app/UI considerations to be made?

Add quality selector to player toolbar

Description

Add support for quality selection within the player. Quality selection is one of the basic functionalities provided in almost all the A/V players out there.
The current Avalon player has an icon in the player toolbar where it shows a list of available stream qualities for the media when you hover over the icon as follows;

Screenshot from 2021-03-16 11-15-21.png
Screenshot from 2021-03-16 11-17-18.png

Done Looks Like

IIIF React media player is able to show multiple qualities from the manifest, and the user can select desired quality to view the media.

Build out wireframes for any new UI needed

Description

It'd be helpful to have some rudimentary wireframes to guide development work.

Done looks like

  • Any UI components which need new UI should have very basic/generic wireframes attached to the issue.

Update markers UI

Description

Update markers UI in VideoJS player.

Done looks like

  • Marker color changed from red to Avalon green
  • Marker highlight size remains contained and doesn't overlap regions.

Update time rail highlight as the player time updates

Is your feature request related to a problem? Please describe.

The player's time can be updated in 3 ways:

  1. Using structure navigation
  2. As the player keeps on playing naturally
  3. User seeking to a specific point of time using the playhead

For all these scenarios the time rail must get highlighted if the current time of the playhead falls within a defined structure item's range. This works when using the structure navigation, but not in the other 2 scenarios.
The time rail highlight stays at the same place where it was last updated through structure navigation as shown in the following screenshot;
Screenshot from 2020-12-10 09-36-30
Here the time fragment of the last clicked structure item is highlighted in the player while the playhead has kept progressing.

Describe the solution you'd like
Keeping consistent with the old player, there are 2 scenarios to consider when implementing a solution to this.

  1. When the current time of the playhead falls within a defined structure item's time fragment: highlight that relevant fragment in the player.
  2. When it's outside of defined structure (there could be ranges with undefined structure): remove the time rail highlighter.

Transcripts UI component - initial investigation

Description

Research how the VideoJS player can hooked to worked synchronously with transcripts. And for the transcript component, what can we use to make it a smooth representation to the user (features like highlighting, auto-scrolling?)

Done Looks Like

  • Find any VideoJS plugins that can be used
  • How to render the transcripts in-sync with the player (text highlights/auto-scrolling)

Examples

Support manifest prop in addition to manifestUrl

Description

The root component can accept a manifest property in addition to manifestUrl. manifest will be the actual JSON file itself, and for testing can import a local manifest from the src/json directory.

Done looks like

  • Player renders a locally supplied manifest
  • If both props are provided (manifest and manifestUrl, the manifest property will take precedence.

Add to playlist component(s) support

Description

Avalon player has the support to add the media to a playlist in the player itself, which needs be added to iiif player
Screenshot from 2020-03-02 14-51-03.png

To see playlists in action see this playlist in one of Avalon's test instances.

Done Looks Like

  • iiif player gives the user ability to add content to a playlist. When clicked on Add to Playlist button, it collapses a form to add the item to a playlist.

Move CSS for structure navigation

Description

Currently the CSS for indicating the active item in the structure is within the StructuredNavigation.scss file which is not getting bundled up in the package. So when you use this component in a host application, structure navigation is not properly visible like below, where the current playing item in the structure is Rinsing Well item, which cannot be seen in the structured navigation component.

Screenshot from 2021-05-21 12-19-38.png

Done Looks Like

CSS for the arrow pointer is included in the main css, which gets bundled. So that, the structure navigation component displays the current item that's being played.
Screenshot from 2021-05-21 13-34-42.png

Add marker support in playlists

Description

Playlists are a feature assumed to be implemented by a host application for the player. Playlists have "Items", which are time-ranged segments of a media file.

Markers are time points within an Item.

In playlists Avalon player has a feature to add markers to items

Screenshot from 2020-03-02 11-32-32.png

image

image

To see how markers work in playlists use this playlist in one of Avalon's test instances. To create a marker click on Add marker to playlist button on the player toolbar.

Done Looks Like

  • "Marker" control is added to the media player via a custom plugin or hooking into marker support from the player itself
  • After initiating the "add marker" action, dropdown UI is built out which looks like the above screen shot.
  • Clicking the "Add Marker" button sends a JSON POST containing the form data

Wire up Add to playlist feature in UI

Description

Avalon player has the support to add the media to a playlist in the player itself, which needs be added to IIIF player. IIIF player gives the user ability to add content to a playlist. When clicked on Add to Playlist button, it collapses a form to add the item to a playlist.

Screenshot from 2020-03-02 14-51-03.png

To see playlists in action see this playlist in one of Avalon's test instances.

Done Looks Like

  • hasPlaylists added as a prop to parent component to turn the feature on/off
  • Playlists UI created
  • Playlist form created and validates user input

Wire up Mediaelement event handlers to new Context pattern for structured navigation

Description

Previously events emitted from Mediaelement.js were handled via Redux, but the new version of the package doesn't use Redux. We need to wire up these event listeners to the new Provider/Context pattern. This issue can focus on handling events for Structured Navigation movement.

https://github.com/mediaelement/mediaelement/blob/master/docs/api.md#events

image

Done looks like

  • Events handled and wired-up for interacting with Structured Navigation

Remove time tooltip for playhead when hovering

Description

When hovering over the progress bar 2 time tool-tips appear;

  1. for the timestamp where the mouse pointer is on the time rail
  2. for the timestamp of the play-head

time tooltip.png

Usually the time tooltip is shown only for the timestamp of the mouse pointer's current position on the time rail.

Done Looks Like

Time tool-tip is shown only for the timestamp, where the mouse pointer is on the time rail.

Update test manifests from v2 to v3

Description

Manifesto is targeting IIIF 3 manifests, but we were using some IIIF Presentation 2 manifests and the parsing was not working correctly.

Done Looks Like

  • Rewrite existing manifest(s) as needed to align with the Presentation 3.0 spec
  • Props in the structure are changed to work correctly with Manifesto

Establish unit testing pattern for new app structure

Description

As the entire application is shifting, we'll need to establish a new pattern or two for how to structure Jest unit tests w/ Testing Library.

Done looks like

  • Remove any unnecessary test dependencies
  • Create a pattern for mocking the new Provider components we're wrapping the application code with

Archive the previous GitHub repository for the iiif-player component

Description

The new component library contains a player with functionality similar to the previous react-iiif-media-player component. Therefore we are not maintaining the previous GitHub repo.

Done Looks Like

  • Update the README.md to reflect that, this work was done as a prototype and we have a new player with similar functionality and features and point the users to the new component library npm package. Later delete the npm package altogether since it's broken
  • Archive the previous repo

Transcripts component wireframe implementation

Description

Transcript UI component is designed and ready to be wired up with the player and structure navigation components

Done Looks Like

  • Finalized design of the transcript component
  • CSS and JSX codes written for the component
  • Component is designed in a way it can be placed in different places with respect to the other component in different layouts

Remove axios, and replace with fetch

Description

With an eye towards an upcoming release, best to limit the amount of dependencies this package is using. Let's use the native fetch API instead of axios

Done looks like

  • axios removed and replaced with fetch
  • axios test mocking removed

Add poster to video player from manifest

Description

When players load video files, a poster is shown in the player until the playback starts. IIIF manifests supports thumbnail property, which can be used to provide details of an image/a short video clip that can be used as a poster.
Use this in the IIIF player when it is created, so that the player doesn't come up with a black window at startup.

Done Looks Like

  • extract thumbnail property from manifest in the parser
  • use the thumbnail in the VideoJS options to render the player with poster

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.