Skip to content
This repository has been archived by the owner on Jan 30, 2018. It is now read-only.

Commit

Permalink
Integrate dash player library and feed with new video player
Browse files Browse the repository at this point in the history
Added dash.js and implemented a HTML5 video player for reddit hosted
videos. This commit includes the integration with the feed and comments
pages and the new video player is currently only used for reddit hosted
content.
  • Loading branch information
MoMitch authored and birakattack committed Jun 26, 2017
1 parent 9d57a69 commit f9a6a1a
Show file tree
Hide file tree
Showing 15 changed files with 1,104 additions and 22 deletions.
12 changes: 12 additions & 0 deletions assets/svg/full-screen-collapse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/svg/full-screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/svg/mute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/svg/replay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/svg/unmute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"branch-sdk": "^2.22.1",
"cluster": "^0.7.7",
"crypto-js": "3.1.8",
"dashjs": "^2.4.1",
"event-tracker": "git://github.com/reddit/event-tracker.git#28bc2dd9ce3b80540fdf189e1b003f8264cd0d08",
"js-cookie": "^2.1.1",
"json-stable-stringify": "^1.0.1",
Expand All @@ -45,8 +46,8 @@
"raf": "^3.2.0",
"raven": "^1.1.1",
"raven-js": "^3.7.0",
"react": "15.0.2",
"react-dom": "15.0.2",
"react": "15.4.0",
"react-dom": "15.4.0",
"react-motion": "0.4.4",
"react-redux": "4.4.5",
"redux": "3.5.2",
Expand All @@ -66,7 +67,7 @@
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-react": "^5.1.1",
"mocha": "2.4.5",
"react-addons-test-utils": "15.0.1",
"react-addons-test-utils": "15.5.0",
"sinon": "1.17.3",
"sinon-chai": "2.8.0",
"webpack-bundle-analyzer": "^2.2.1"
Expand Down
1 change: 1 addition & 0 deletions src/apiClient/models/PostModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default class PostModel extends RedditModel {
thirdPartyTracking2: T.string,
thirdPartyTrackers: T.string,
userReports: T.array,
videoPlaytime: T.number,

// derived
expandable: T.bool,
Expand Down
19 changes: 19 additions & 0 deletions src/app/actions/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ export const toggleHidePost = postId => async (dispatch, getState) => {
}
};

export const updatePostPlaytime = (postId, newPlaytime) => async (dispatch, getState) => {
const state = getState();
const post = state.posts[postId];

try {
const newPost = PostModel.fromJSON({ ...post.toJSON(), videoPlaytime: newPlaytime });
dispatch(updatePlaying(newPost));
} catch (e) {
console.error(e);
}
};

export const TOGGLE_EDIT = 'POSTS__TOGGLE_EDIT';
export const toggleEdit = postId => ({
type: TOGGLE_EDIT,
Expand All @@ -124,6 +136,13 @@ export const stopPlaying = postId => ({
thingId: postId,
});

//Video time must be kept current so that reports can be generated with video time
export const UPDATE_VIDEO_TIME = 'POSTS__UPDATE_VIDEO_TIME';
export const updatePlaying = (post) => ({
type: UPDATE_VIDEO_TIME,
post: post,
});

export const UPDATING_SELF_TEXT = 'POSTS__UPDATING_SELF_TEXT';
export const updatingSelfText = postId => ({
type: UPDATING_SELF_TEXT,
Expand Down
12 changes: 10 additions & 2 deletions src/app/actions/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const report = thingId => async (dispatch, getState) => {
const thing = modelFromThingId(thingId, state);
const thingType = ModelTypes.thingType(thingId);
const usesSubredditRules = SubredditRule.doRulesApplyToThingType(thingType);

const props = {
thingId,
thingType,
Expand All @@ -33,6 +33,11 @@ export const report = thingId => async (dispatch, getState) => {
props.subredditName = thing.subreddit;
}

//If video playtime exists (video was playing when report generated) submit it with the report
if (thing.videoPlaytime) {
props.videoPlaytime = thing.videoPlaytime;
}

dispatch({
type: REPORT,
modalType: MODAL_TYPE,
Expand Down Expand Up @@ -68,11 +73,15 @@ export const submit = report => async (dispatch, getState) => {
const username = state.user.name;

try {
const model = modelFromThingId(report.thingId, state);
report.reportTime = model.videoPlaytime;

const body = {
// 'reason' is either the shortname of a rule, or a special keyword
// The naming in the api is... it could be better.
reason: report.ruleName,
thing_id: report.thingId,
report_time: report.reportTime,
api_type: 'json',
};

Expand All @@ -90,7 +99,6 @@ export const submit = report => async (dispatch, getState) => {
body,
});

const model = modelFromThingId(report.thingId, state);
let moderatesSub = false;

if (state.moderatingSubreddits && includes(state.moderatingSubreddits.names, model.subreddit)) {
Expand Down
Loading

0 comments on commit f9a6a1a

Please sign in to comment.