-
Notifications
You must be signed in to change notification settings - Fork 414
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
track and manage video state #890
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! I see you are tracking time when the video pauses, I was hoping that you would update the time using this listener instead https://www.w3schools.com/tags/av_event_timeupdate.asp
i.e. mediaElement.addEventListener("timeupdate", doUpdatePlayback);
Are we using the time for something other than starting back where the user left off? |
@daovist yes, exactly. There are going to be several features that depend on this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall excellent PR! I tested it locally and it works well, but there are a few small changes before it can be merged.
@@ -0,0 +1,15 @@ | |||
import * as settings from "constants/settings"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that /selectors/video.js
has not been deleted. Are we still using it?
src/renderer/store.js
Outdated
@@ -71,6 +72,7 @@ const reducers = combineReducers({ | |||
shapeShift: shapeShiftReducer, | |||
subscriptions: subscriptionsReducer, | |||
video: videoReducer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need video: videoReducer,
?
|
||
export const makeSelectMediaPositionForUri = uri => | ||
createSelector(_selectState, state => { | ||
const id = uri.split("#")[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this work when the uri does not contain a #
such as in the case of lbry://one
?
src/renderer/redux/reducers/media.js
Outdated
|
||
export type MediaState = { | ||
paused: Boolean, | ||
positions: Object, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you define a type more specifically than Object
? Maybe { [string]: number }
?
@@ -93,6 +96,9 @@ class Video extends React.PureComponent { | |||
} | |||
const poster = metadata.thumbnail; | |||
|
|||
const mediaId = uri.split("#")[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I said in a comment below, does this work for lbry://one
?
@@ -93,6 +96,9 @@ class Video extends React.PureComponent { | |||
} | |||
const poster = metadata.thumbnail; | |||
|
|||
const mediaId = uri.split("#")[1]; | |||
console.log("mediaId:", mediaId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove when ready to merge :)
}); | ||
|
||
const perform = dispatch => ({ | ||
play: uri => dispatch(doPlayUri(uri)), | ||
cancelPlay: () => dispatch(doSetPlayingUri(null)), | ||
changeVolume: volume => dispatch(doChangeVolume(volume)), | ||
setVideoPause: val => dispatch(setVideoPause(val)), | ||
// setVideoPause: val => dispatch(setVideoPause(val)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this comment when ready to merge
@@ -15,7 +16,11 @@ import { | |||
} from "redux/selectors/file_info"; | |||
import { makeSelectCostInfoForUri } from "redux/selectors/cost_info"; | |||
import { selectShowNsfw } from "redux/selectors/settings"; | |||
import { selectVideoPause } from "redux/selectors/video"; | |||
// import { selectVideoPause } from "redux/selectors/video"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this comment when ready to merge
@@ -3,7 +3,8 @@ import { connect } from "react-redux"; | |||
import { doChangeVolume } from "redux/actions/app"; | |||
import { selectVolume } from "redux/selectors/app"; | |||
import { doPlayUri, doSetPlayingUri } from "redux/actions/content"; | |||
import { setVideoPause } from "redux/actions/video"; | |||
import { doPlay, doPause, savePosition } from "redux/actions/media"; | |||
// import { setVideoPause } from "redux/actions/video"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this comment when ready to merge :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor code feedback, as well as the feedback given in office that it would be excellent if the video showed the same frame it was on prior to hitting play.
setVideoPause: val => dispatch(setVideoPause(val)), | ||
doPlay: () => dispatch(doPlay()), | ||
doPause: () => dispatch(doPause()), | ||
savePosition: (id, position) => dispatch(savePosition(id, position)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what kind of id? I assume this is a claimId
, let's call it that
doPause, | ||
savePosition, | ||
mediaPaused, | ||
mediaPosition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that Video
is receiving so many properties simply to pass them on to VideoPlayer
makes me think VideoPlayer
should just be a first-class component. Although perhaps the names should be clarified if this is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking it should be its own component. Maybe as a separate issue along with displaying a paused video instead of the image wrapper when position has a value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. #825 can work as a reference as the media component has been separated there. Also I think that Video and VideoPlayer names are very specific, we use the same component to render all other types of media as well, so IMO the variables and components should be refactored to reflect the same(also in the PR).
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good, im just going to check this out locally, but otherwise im happy with it
componentWillReceiveProps(next) { | ||
const el = this.refs.media.children[0]; | ||
if (!this.props.paused && next.paused && !el.paused) el.pause(); | ||
// if (this.props.paused && !next.paused && el.paused) el.play(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment please
This feature tracks play and pause actions on a video element. Below is a model of the parts.
blue = state
red = actions
purple = reducers
light blue = selectors
green = component lifecycle hooks
orange = distant component which can alter state
black = not React/Redux