remove media.paused; catch file open pause from change of content.playingUri
This commit is contained in:
parent
f1a799374a
commit
82252e6985
12 changed files with 17 additions and 88 deletions
|
@ -7,8 +7,7 @@ import {
|
|||
makeSelectClaimForUri,
|
||||
} from 'lbry-redux';
|
||||
import { doOpenFileInShell } from 'redux/actions/file';
|
||||
import { doPurchaseUri, doStartDownload } from 'redux/actions/content';
|
||||
import { doPause } from 'redux/actions/media';
|
||||
import { doPurchaseUri, doStartDownload, doSetPlayingUri } from 'redux/actions/content';
|
||||
import FileDownloadLink from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
|
@ -24,7 +23,7 @@ const perform = dispatch => ({
|
|||
openInShell: path => dispatch(doOpenFileInShell(path)),
|
||||
purchaseUri: uri => dispatch(doPurchaseUri(uri)),
|
||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||
doPause: () => dispatch(doPause()),
|
||||
pause: () => dispatch(doSetPlayingUri(null)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
|
|
@ -22,7 +22,7 @@ type Props = {
|
|||
restartDownload: (string, number) => void,
|
||||
openInShell: string => void,
|
||||
purchaseUri: string => void,
|
||||
doPause: () => void,
|
||||
pause: () => void,
|
||||
};
|
||||
|
||||
class FileDownloadLink extends React.PureComponent<Props> {
|
||||
|
@ -50,14 +50,13 @@ class FileDownloadLink extends React.PureComponent<Props> {
|
|||
purchaseUri,
|
||||
costInfo,
|
||||
loading,
|
||||
doPause,
|
||||
claim,
|
||||
pause,
|
||||
} = this.props;
|
||||
|
||||
const openFile = () => {
|
||||
if (fileInfo) {
|
||||
openInShell(fileInfo.download_path);
|
||||
doPause();
|
||||
pause();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import * as settings from 'constants/settings';
|
|||
import { doChangeVolume } from 'redux/actions/app';
|
||||
import { selectVolume } from 'redux/selectors/app';
|
||||
import { doPlayUri, doSetPlayingUri, savePosition } from 'redux/actions/content';
|
||||
import { doPlay, doPause } from 'redux/actions/media';
|
||||
import {
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectContentTypeForUri,
|
||||
|
@ -15,7 +14,6 @@ import {
|
|||
selectSearchBarFocused,
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectClientSetting, selectShowNsfw } from 'redux/selectors/settings';
|
||||
import { selectMediaPaused } from 'redux/selectors/media';
|
||||
import { selectPlayingUri, makeSelectContentPositionForUri } from 'redux/selectors/content';
|
||||
import { selectFileInfoErrors } from 'redux/selectors/file_info';
|
||||
import FileViewer from './view';
|
||||
|
@ -31,7 +29,6 @@ const select = (state, props) => ({
|
|||
playingUri: selectPlayingUri(state),
|
||||
contentType: makeSelectContentTypeForUri(props.uri)(state),
|
||||
volume: selectVolume(state),
|
||||
mediaPaused: selectMediaPaused(state),
|
||||
playbackPosition: makeSelectContentPositionForUri(props.uri)(state),
|
||||
autoplay: makeSelectClientSetting(settings.AUTOPLAY)(state),
|
||||
searchBarFocused: selectSearchBarFocused(state),
|
||||
|
@ -42,8 +39,6 @@ const perform = dispatch => ({
|
|||
play: uri => dispatch(doPlayUri(uri)),
|
||||
cancelPlay: () => dispatch(doSetPlayingUri(null)),
|
||||
changeVolume: volume => dispatch(doChangeVolume(volume)),
|
||||
doPlay: () => dispatch(doPlay()),
|
||||
doPause: () => dispatch(doPause()),
|
||||
savePosition: (claimId, outpoint, position) =>
|
||||
dispatch(savePosition(claimId, outpoint, position)),
|
||||
});
|
||||
|
|
|
@ -27,9 +27,11 @@ class MediaPlayer extends React.PureComponent {
|
|||
this.toggleFullScreenVideo = this.toggleFullScreen.bind(this);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentDidUpdate(nextProps) {
|
||||
const el = this.refs.media.children[0];
|
||||
if (!this.props.paused && nextProps.paused && !el.paused) el.pause();
|
||||
if (this.props.playingUri && !nextProps.playingUri && !el.paused) {
|
||||
el.pause();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -87,8 +89,6 @@ class MediaPlayer extends React.PureComponent {
|
|||
const mediaElement = this.media.children[0];
|
||||
if (mediaElement) {
|
||||
mediaElement.currentTime = position || 0;
|
||||
mediaElement.addEventListener('play', () => this.props.doPlay());
|
||||
mediaElement.addEventListener('pause', () => this.props.doPause());
|
||||
mediaElement.addEventListener('timeupdate', () =>
|
||||
this.props.savePosition(
|
||||
claim.claim_id,
|
||||
|
@ -140,7 +140,6 @@ class MediaPlayer extends React.PureComponent {
|
|||
if (mediaElement) {
|
||||
mediaElement.removeEventListener('click', this.togglePlayListener);
|
||||
}
|
||||
this.props.doPause();
|
||||
}
|
||||
|
||||
toggleFullScreen(event) {
|
||||
|
|
|
@ -34,10 +34,7 @@ type Props = {
|
|||
volume: number,
|
||||
claim: Claim,
|
||||
uri: string,
|
||||
doPlay: () => void,
|
||||
doPause: () => void,
|
||||
savePosition: (string, string, number) => void,
|
||||
mediaPaused: boolean,
|
||||
playbackPosition: ?number,
|
||||
className: ?string,
|
||||
obscureNsfw: boolean,
|
||||
|
@ -202,10 +199,7 @@ class FileViewer extends React.PureComponent<Props> {
|
|||
volume,
|
||||
claim,
|
||||
uri,
|
||||
doPlay,
|
||||
doPause,
|
||||
savePosition,
|
||||
mediaPaused,
|
||||
playbackPosition,
|
||||
className,
|
||||
obscureNsfw,
|
||||
|
@ -237,6 +231,7 @@ class FileViewer extends React.PureComponent<Props> {
|
|||
<div className={classnames('video', {}, className)}>
|
||||
{isPlaying && (
|
||||
<div className="content__view">
|
||||
<p>hai</p>
|
||||
{!isReadyToPlay ? (
|
||||
<div className={layoverClass} style={layoverStyle}>
|
||||
<LoadingScreen status={loadStatusMessage} />
|
||||
|
@ -251,13 +246,11 @@ class FileViewer extends React.PureComponent<Props> {
|
|||
downloadCompleted={fileInfo.completed}
|
||||
changeVolume={changeVolume}
|
||||
volume={volume}
|
||||
doPlay={doPlay}
|
||||
doPause={doPause}
|
||||
savePosition={savePosition}
|
||||
claim={claim}
|
||||
uri={uri}
|
||||
paused={mediaPaused}
|
||||
position={playbackPosition}
|
||||
playingUri={playingUri}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -182,13 +182,6 @@ export const FETCH_SUBSCRIPTIONS_START = 'FETCH_SUBSCRIPTIONS_START';
|
|||
export const FETCH_SUBSCRIPTIONS_FAIL = 'FETCH_SUBSCRIPTIONS_FAIL';
|
||||
export const FETCH_SUBSCRIPTIONS_SUCCESS = 'FETCH_SUBSCRIPTIONS_SUCCESS';
|
||||
|
||||
// Video controls
|
||||
export const SET_VIDEO_PAUSE = 'SET_VIDEO_PAUSE';
|
||||
|
||||
// Media controls
|
||||
export const MEDIA_PLAY = 'MEDIA_PLAY';
|
||||
export const MEDIA_PAUSE = 'MEDIA_PAUSE';
|
||||
|
||||
// Publishing
|
||||
export const CLEAR_PUBLISH = 'CLEAR_PUBLISH';
|
||||
export const UPDATE_PUBLISH_FORM = 'UPDATE_PUBLISH_FORM';
|
||||
|
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from 'lbry-redux';
|
||||
import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||
import { selectMediaPaused } from 'redux/selectors/media';
|
||||
import { doPrepareEdit } from 'redux/actions/publish';
|
||||
import FilePage from './view';
|
||||
|
||||
|
@ -31,7 +30,6 @@ const select = (state, props) => ({
|
|||
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
|
||||
subscriptions: selectSubscriptions(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
isPaused: selectMediaPaused(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
autoplay: makeSelectClientSetting(settings.AUTOPLAY)(state),
|
||||
});
|
||||
|
@ -46,4 +44,7 @@ const perform = dispatch => ({
|
|||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FilePage);
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(FilePage);
|
||||
|
|
|
@ -16,8 +16,8 @@ import Native from 'native';
|
|||
import { doFetchRewardedContent } from 'redux/actions/content';
|
||||
import { doFetchDaemonSettings } from 'redux/actions/settings';
|
||||
import { doAuthNavigate } from 'redux/actions/navigation';
|
||||
import { doPause } from 'redux/actions/media';
|
||||
import { doCheckSubscriptionsInit } from 'redux/actions/subscriptions';
|
||||
import { doAuthenticate } from 'redux/actions/user';
|
||||
import { doCheckSubscriptions } from 'redux/actions/subscriptions';
|
||||
import {
|
||||
selectIsUpgradeSkipped,
|
||||
selectUpdateUrl,
|
||||
|
@ -109,9 +109,6 @@ export function doDownloadUpgradeRequested() {
|
|||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
// Pause video if needed
|
||||
dispatch(doPause());
|
||||
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
|
||||
if (['win32', 'darwin'].includes(process.platform)) {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// @flow
|
||||
import * as actions from 'constants/action_types';
|
||||
import type { Dispatch } from 'redux/reducers/media';
|
||||
|
||||
export const doPlay = () => (dispatch: Dispatch) =>
|
||||
dispatch({
|
||||
type: actions.MEDIA_PLAY,
|
||||
});
|
||||
|
||||
export const doPause = () => (dispatch: Dispatch) =>
|
||||
dispatch({
|
||||
type: actions.MEDIA_PAUSE,
|
||||
});
|
|
@ -1,27 +0,0 @@
|
|||
// @flow
|
||||
import * as actions from 'constants/action_types';
|
||||
import { handleActions } from 'util/redux-utils';
|
||||
|
||||
export type MediaState = {
|
||||
paused: Boolean,
|
||||
};
|
||||
|
||||
export type Action = any;
|
||||
export type Dispatch = (action: Action) => any;
|
||||
|
||||
const defaultState = { paused: true, positions: {} };
|
||||
|
||||
export default handleActions(
|
||||
{
|
||||
[actions.MEDIA_PLAY]: (state: MediaState, action: Action) => ({
|
||||
...state,
|
||||
paused: false,
|
||||
}),
|
||||
|
||||
[actions.MEDIA_PAUSE]: (state: MediaState, action: Action) => ({
|
||||
...state,
|
||||
paused: true,
|
||||
}),
|
||||
},
|
||||
defaultState
|
||||
);
|
|
@ -1,5 +0,0 @@
|
|||
import { createSelector } from 'reselect';
|
||||
|
||||
const selectState = state => state.media || {};
|
||||
|
||||
export const selectMediaPaused = createSelector(selectState, state => state.paused);
|
|
@ -17,7 +17,6 @@ import settingsReducer from 'redux/reducers/settings';
|
|||
import userReducer from 'redux/reducers/user';
|
||||
import shapeShiftReducer from 'redux/reducers/shape_shift';
|
||||
import subscriptionsReducer from 'redux/reducers/subscriptions';
|
||||
import mediaReducer from 'redux/reducers/media';
|
||||
import publishReducer from 'redux/reducers/publish';
|
||||
import { persistStore, autoRehydrate } from 'redux-persist';
|
||||
import createCompressor from 'redux-persist-transform-compress';
|
||||
|
@ -69,7 +68,6 @@ const reducers = combineReducers({
|
|||
user: userReducer,
|
||||
shapeShift: shapeShiftReducer,
|
||||
subscriptions: subscriptionsReducer,
|
||||
media: mediaReducer,
|
||||
publish: publishReducer,
|
||||
notifications: notificationsReducer,
|
||||
blacklist: blacklistReducer,
|
||||
|
|
Loading…
Add table
Reference in a new issue