Giter Club home page Giter Club logo

dash-player's Introduction

Dash Player

GitHub GitHub stars

Dash Player is a Dash component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia, Mixcloud, and DailyMotion. It is wrapped around the ReactPlayer component.

For more detailed documentation on Dash Player and how to use it, visit the official Dash Player documentation page

For updates and more, please see the ongoing changes to this repository's issue tracker or the Dash community discussion on Dash Player.

This is a custom community component, so if your organization or company is interested in sponsoring enhancements to this project, please reach out to the Plotly Dash team.

Getting started

Here are the following steps to get started with using Dash Player in your own Dash apps

$ pip install dash-player

Documentation

Prop Description Default
id The ID used to identify this component in Dash callbacks.
className The CSS class used to identify this component in external stylesheets.
url The url of the media to be played.
playing Whether or not the media is currently playing. Can be set to True or False to play and pause the media, respectively. false
loop Whether or not the media will loop once the player reaches the end. Can be set to True or False to set looping on or off, respectively. false
controls Set to true or false to display native player controls. Vimeo, Twitch and Wistia player will always display controls. false
volume A number between 0 and 1 representing the volume of the player. If set to None, Dash Player ises default volume on all players. null
muted Set to true or false to mute or unmute player volume, respectively. Only works if volume is set. false
playbackRate Set the playback rate of the player (only supported by YouTube, Wistia, and file paths).
width A number or string representing the pixel width of the player. 640px
height A number or string representing the pixel height of the player. 360px
style Optional additional CSS styles. If width or height are supplied within style, then this will override the component-level width or height. {}
playsinline Applies the html5 playsinline attribute where supported, which allows videos to be played inline and will not automatically enter fullscreen mode when playback begins (for iOS). false
currentTime Returns the number of seconds that have been played
secondsLoaded Returns the number of seconds that have been loaded
duration Returns the duration (in seconds) of the currently playing media
intervalCurrentTime Interval in milliseconds at which currentTime prop is updated. 40
intervalSecondsLoaded Interval in milliseconds at which secondsLoaded prop is updated. 500
intervalDuration Interval in milliseconds at which duration prop is updated. 500
seekTo Seek to the given number of seconds, or fraction if amount is between 0 and 1 null

Built With

  • Dash - Main server and interactive components
  • ReactPlayer - The react component that was wrapped by this

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

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

License

This project is licensed under the MIT License - see the LICENSE file for details

Partnership

Changes to dash-player were sponsored by Volkswagen's Center of Excellence for Battery Systems.

dash-player's People

Contributors

alexcjohnson avatar alexshoe avatar dependabot[bot] avatar gvwilson avatar liamconnors avatar nicolaskruchten avatar rpkyle avatar srhm-ca avatar ycaokris avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dash-player's Issues

Set 'seekTo' to seconds between 0 and 1

When using the 'seekTo' parameter in dash_player.DashPlayer, the value i set is interpreted as a fraction of the total duration if it lies between 0 and 1, rather than as an absolute time in seconds.

This can lead to the player jumping to an unintended point if i do need the player to jump to 0~1s.

How can i solve it?

Add Testing

  • Add basic testing to this codebase to help simplify further development and PR reviewing

minor cleanup items

Nice job @alexshoe on the 1.0.0 release! Couple of things I noticed after it went out:

  • Delete the obsolete dev bundle file which is still included in the package, will shrink the package size a good deal.
  • Use node 16 / npm 7 or 8, so that we get a package-lock.json with "lockfileVersion": 2 (thanks @archmoj)

Provide `is_playing` property

Currently there is no obvious way to determine within a callback, if the video is currently playing or not.

The existing playing property is not synchronized with the actual playback of the video as can be seen on the example page https://dash.plotly.com/dash-player
Specificall, the video can be started and stopped when clicking the checkbox but when starting the video playback with the video, the property is not changed.

This is not due to the specific example as a modficiation with printing the current state of the playing variable e.g.

@app.callback(
    Output("current-time-div", "children"),
    Input("player", "currentTime"),
    State("player", "playing"),
)
def display_currentTime(currentTime, playing):
    print(playing)
    return f"Current Time: {currentTime}"

shows: The value of playing can be False while the video is in fact playing by clicking on the play button within the video.

It would be great to either have the playing property synchronized with the actual video playback or provide a new isPlaying property that reflects the actual video playing state.
The same is true for the muted property (and possibly others).

Can this component stream UDP video stream

Looking for info as to whether this component can play video from x265 stream via a UDP port.

If so, on which machine should the UDP stream be pointed. On the machine producing the DASH app or on the machine consuming the Dash App.

Appreciate any clarification.

Callback Bug

In the demo code, if the "seek-to" button is dropped, the other states don't update.
Reproducible example:

from dash import Dash, html, Input, Output, State
import dash_player

app = Dash(__name__)

app.scripts.config.serve_locally = True

app.layout = html.Div(
    [
        dash_player.DashPlayer(
            id="video-player",
            url="http://media.w3.org/2010/05/bunny/movie.ogv",
            controls=True,
        ),
        # html.Button("Set seekTo to 10", id="button-seek-to"), 
        html.Div(id="div-current-time", style={"margin-bottom": "20px"}),
        html.Div(id="div-method-output"),
    ]
)


@app.callback(
    Output("div-current-time", "children"), Input("video-player", "currentTime")
)
def update_time(currentTime):
    return "Current Time: {}".format(currentTime)


@app.callback(
    Output("div-method-output", "children"),
    Input("video-player", "secondsLoaded"),
    State("video-player", "duration"),
)
def update_methods(secondsLoaded, duration):
    return "Second Loaded: {}, Duration: {}".format(secondsLoaded, duration)


if __name__ == "__main__":
    app.run_server(debug=True)

I assumed it could be an issue with the property being defined, so I tried supplying the seekTo property in the constructor of the component e.g;

        dash_player.DashPlayer(
            id="video-player",
            url="http://media.w3.org/2010/05/bunny/movie.ogv",
            controls=True,
            seekTo=10
        )

It may need to be assigned in the constructor too.

CSS classes

Hi,
can CSS classes be used for the component, similar to Dash html components, using the classname attribute?

Error at Chrome Console

#14 is still occurring on the latest version

dash_player.v1_0_6m1677851916.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'getSecondsLoaded')
    at y.value (dash_player.v1_0_6m1677851916.min.js:1:111522)
value @ dash_player.v1_0_6m1677851916.min.js:1
4dash_player.v1_0_6m1677851916.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'getCurrentTime')
    at y.value (dash_player.v1_0_6m1677851916.min.js:1:111340)
value @ dash_player.v1_0_6m1677851916.min.js:1
dash_player.v1_0_6m1677851916.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'getDuration')
    at y.value (dash_player.v1_0_6m1677851916.min.js:1:111703)
value @ dash_player.v1_0_6m1677851916.min.js:1

dash-player/metadata.json not commited

Hey, found your dash component wrapper for this player and was interested in trying it out, but when trying to import dash-player, it says No such file or directory: '/code/dash_player/metadata.json'.

I admit to not knowing exactly how making a Dash component works, but I found an issue on the base dash-core-components which pointed me to the .gitignore file, and it seems that the dash-player/metadata.json file is not being tracked, but is required to run this player.

video player crashes

Hi,

Sometimes, the video player crashes and does not play the video. Even when I restart the script and the browser.

It only shows the frames when I move forward or backward.

console error

a
b

No problem with playback, but console error exposed

mycode in layout:
c

Error on DashPlayer.react.js at chrome console

Errors:
this.refs.player.getCurrentTime();
Uncaught TypeError: Cannot read property 'getCurrentTime' of undefined

this.refs.player.getSecondsLoaded();
Uncaught TypeError: Cannot read property 'getSecondsLoaded' of undefined

this.refs.player.getDuration();
Uncaught TypeError: Cannot read property 'getDuration' of undefined

pip list | grep dash

dash                               1.8.0
dash-core-components               1.7.0
dash-html-components               1.0.2
dash-player                        0.0.1
dash-renderer                      1.2.3
dash-table                         4.6.0

Q

what's the difference with DashPlayer that used by many videosites?
and why so few stars?

Is it production ready?

I want to use it in a very important application.
Please let me know if it is safe to use in production? Thank you!

usage-advenced doesn't work

Hi,

I am trying to use current time feature of this tool to control a custom timeline. However in the given example code, current time text doesn't get updated until I stop the video. Which is suboptimal and in here it is updated continuously. Can you help me to make it get updated as the video flows?

Thank you

Dash-player==1.0.3
Dash==2.7.0
Flask==2.2.2
Plotly==5.11.0

I have tested this on both windows 10 and WSL2

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.