Initial commit of dashPlayer package for R (#9)

This commit is contained in:
Ryan Patrick Kyle 2019-07-04 12:29:29 -04:00 committed by GitHub
parent 39786a4e71
commit 3335bfefeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 666 additions and 6 deletions

28
.Rbuildignore Normal file
View File

@ -0,0 +1,28 @@
# ignore JS config files/folders
node_modules/
coverage/
src/
lib/
.babelrc
.builderrc
.eslintrc
.npmignore
# demo folder has special meaning in R
# this should hopefully make it still
# allow for the possibility to make R demos
demo/.*\.js
demo/.*\.html
demo/.*\.css
# ignore python files/folders
setup.py
index.py
config.py
requirements.txt
MANIFEST.in
CHANGELOG.md
tests/
.pylintrc
^.*\.Rproj$
^\.Rproj\.user$

16
DESCRIPTION Normal file
View File

@ -0,0 +1,16 @@
Package: dashPlayer
Title: Dash player component for videos
Version: 0.0.1
Authors @R: as.person(c(Xing Han Lu <xinghan@plot.ly>))
Description: Dash player component for videos
Depends: R (>= 3.0.2)
Imports:
dash (>= 0.1.0)
Suggests:
License: MIT + file LICENSE
URL: https://github.com/plotly/dash-html-components
BugReports: https://github.com/plotly/dash-html-components/issues
Encoding: UTF-8
LazyData: true
Author: Xing Han Lu [aut]
Maintainer: Ryan Patrick Kyle <ryan@plot.ly>

4
NAMESPACE Normal file
View File

@ -0,0 +1,4 @@
# AUTO GENERATED FILE - DO NOT EDIT
export(dashPlayer)
import(dash)

18
R/dashPlayer.R Normal file
View File

@ -0,0 +1,18 @@
# AUTO GENERATED FILE - DO NOT EDIT
dashPlayer <- function(id=NULL, url=NULL, playing=NULL, loop=NULL, controls=NULL, volume=NULL, muted=NULL, playbackRate=NULL, width=NULL, height=NULL, style=NULL, playsinline=NULL, currentTime=NULL, secondsLoaded=NULL, duration=NULL, intervalCurrentTime=NULL, intervalSecondsLoaded=NULL, intervalDuration=NULL, seekTo=NULL) {
props <- list(id=id, url=url, playing=playing, loop=loop, controls=controls, volume=volume, muted=muted, playbackRate=playbackRate, width=width, height=height, style=style, playsinline=playsinline, currentTime=currentTime, secondsLoaded=secondsLoaded, duration=duration, intervalCurrentTime=intervalCurrentTime, intervalSecondsLoaded=intervalSecondsLoaded, intervalDuration=intervalDuration, seekTo=seekTo)
if (length(props) > 0) {
props <- props[!vapply(props, is.null, logical(1))]
}
component <- list(
props = props,
type = 'DashPlayer',
namespace = 'dash_player',
propNames = c('id', 'url', 'playing', 'loop', 'controls', 'volume', 'muted', 'playbackRate', 'width', 'height', 'style', 'playsinline', 'currentTime', 'secondsLoaded', 'duration', 'intervalCurrentTime', 'intervalSecondsLoaded', 'intervalDuration', 'seekTo'),
package = 'dashPlayer'
)
structure(component, class = c('dash_component', 'list'))
}

26
R/internal.R Normal file
View File

@ -0,0 +1,26 @@
.dashPlayer_js_metadata <- function() {
deps_metadata <- list(`dash_player` = structure(list(name = "dash_player",
version = "0.0.1", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'dash_player.min.js',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashPlayer",
all_files = FALSE), class = "html_dependency"))
return(deps_metadata)
}
dash_assert_valid_wildcards <- function (attrib = list("data", "aria"), ...)
{
args <- list(...)
validation_results <- lapply(names(args), function(x) {
grepl(paste0("^", attrib, "-[a-zA-Z0-9]{1,}$", collapse = "|"),
x)
})
if (FALSE %in% validation_results) {
stop(sprintf("The following wildcards are not currently valid in Dash: '%s'",
paste(names(args)[grepl(FALSE, unlist(validation_results))],
collapse = ", ")), call. = FALSE)
}
else {
return(args)
}
}

4
dash-info.yaml Normal file
View File

@ -0,0 +1,4 @@
pkg_help_description: >
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 react-player component.
pkg_help_title: >
Interactive Media Player Component for Dash

File diff suppressed because one or more lines are too long

1
inst/deps/dash_player.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
man/dashPlayer-package.Rd Normal file
View File

@ -0,0 +1,13 @@
% Auto-generated: do not edit by hand
\docType{package}
\name{dashPlayer-package}
\alias{dashPlayer}
\title{Interactive Media Player Component for Dash
}
\description{
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 react-player component.
}
\author{
\strong{Maintainer}: Ryan Patrick Kyle <ryan@plot.ly>
}

110
man/dashPlayer.Rd Normal file
View File

@ -0,0 +1,110 @@
% Auto-generated: do not edit by hand
\name{dashPlayer}
\alias{dashPlayer}
\title{DashPlayer component}
\description{
A Dash component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia, Mixcloud, and DailyMotion.
}
\usage{
dashPlayer(id=NULL, url=NULL, playing=NULL, loop=NULL, controls=NULL, volume=NULL,
muted=NULL, playbackRate=NULL, width=NULL, height=NULL, style=NULL,
playsinline=NULL, currentTime=NULL, secondsLoaded=NULL, duration=NULL,
intervalCurrentTime=NULL, intervalSecondsLoaded=NULL, intervalDuration=NULL,
seekTo=NULL)
}
\arguments{
\item{id}{Character. The ID used to identify this compnent in Dash callbacks}
\item{url}{Character. The url of a video or song to play
◦ Can be an array or MediaStream object}
\item{playing}{Logical. Set to true or false to pause or play the media}
\item{loop}{Logical. Set to true or false to loop the media}
\item{controls}{Logical. Set to true or false to display native player controls
Vimeo, Twitch and Wistia player will always display controls}
\item{volume}{Numeric. Set the volume of the player, between 0 and 1
null uses default volume on all players}
\item{muted}{Logical. Mutes the player
Only works if volume is set}
\item{playbackRate}{Numeric. Set the playback rate of the player
Only supported by YouTube, Wistia, and file paths}
\item{width}{Character. Set the width of the player}
\item{height}{Character. Set the height of the player}
\item{style}{Named list. Add inline styles to the root element}
\item{playsinline}{Logical. 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).}
\item{currentTime}{Numeric. Returns the number of seconds that have been played}
\item{secondsLoaded}{Numeric. Returns the number of seconds that have been loaded}
\item{duration}{Numeric. Returns the duration (in seconds) of the currently playing media}
\item{intervalCurrentTime}{Numeric. Interval in milliseconds at which currenTtime prop is updated.}
\item{intervalSecondsLoaded}{Numeric. Interval in milliseconds at which secondsLoaded prop is updated.}
\item{intervalDuration}{Numeric. Interval in milliseconds at which duration prop is updated.}
\item{seekTo}{Numeric. Seek to the given number of seconds, or fraction if amount is between 0 and 1}
}
\examples{
\dontrun{
library(dash)
library(dashHtmlComponents)
library(dashCoreComponents)
library(dashPlayer)
app <- Dash$new()
app$layout(
htmlDiv(list(
htmlDiv(
children = list(
dashPlayer(
id = 'video-player',
controls = TRUE,
width='100\%'
)
)
),
htmlDiv(list(
dccInput(id = 'input-url',
value = 'http://media.w3.org/2010/05/bunny/movie.mp4'),
htmlButton(children = 'Change URL',
id = 'button-update-url')
)
)
)
)
)
app$callback(output=list(id='video-player', property='url'),
params=list(
input(id='button-update-url', property='n_clicks'),
state(id='input-url', property='value')),
function(n_clicks, value)
{
return(value)
}
)
app$run_server()
}
}

View File

@ -14,8 +14,13 @@
"build:all": "npm run build:js && npm run build:js-dev && npm run build:py", "build:all": "npm run build:js && npm run build:js-dev && npm run build:py",
"build:all-activated": "(. venv/bin/activate || venv\\scripts\\activate && npm run build:all)" "build:all-activated": "(. venv/bin/activate || venv\\scripts\\activate && npm run build:all)"
}, },
"author": "kris ycaokris@plot.ly", "author": "Xing Han Lu <xinghan@plot.ly>",
"maintainer": "Ryan Patrick Kyle <ryan@plot.ly>",
"license": "MIT", "license": "MIT",
"bugs": {
"url": "https://github.com/plotly/dash-html-components/issues"
},
"homepage": "https://github.com/plotly/dash-html-components",
"dependencies": { "dependencies": {
"react-player": "1.6.4", "react-player": "1.6.4",
"ramda": "^0.25.0", "ramda": "^0.25.0",
@ -25,22 +30,22 @@
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-eslint": "^8.2.3", "babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
"copyfiles": "^2.0.0",
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"copyfiles": "^2.0.0",
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.9.1", "eslint-plugin-react": "^7.9.1",
"npm": "^6.1.0", "npm": "^6.1.0",
"react-docgen": "^2.20.1", "react": ">=0.14",
"react-docgen": "^2.21.0",
"react-dom": ">=0.14",
"style-loader": "^0.21.0", "style-loader": "^0.21.0",
"webpack": "^4.20.2", "webpack": "^4.20.2",
"webpack-cli": "^3.1.1", "webpack-cli": "^3.1.1",
"webpack-serve": "^1.0.2", "webpack-serve": "^1.0.2"
"react": ">=0.14",
"react-dom": ">=0.14"
}, },
"engines": { "engines": {
"node": ">=8.11.0", "node": ">=8.11.0",