partial new livestream api support
This commit is contained in:
parent
dbc98e8902
commit
17d5d5c73b
4 changed files with 53 additions and 23 deletions
|
@ -165,7 +165,9 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
const playerServerRef = useRef();
|
||||
|
||||
const { url: livestreamVideoUrl } = activeLivestreamForChannel || {};
|
||||
const showQualitySelector = !isLivestreamClaim || (livestreamVideoUrl && livestreamVideoUrl.includes('/transcode/'));
|
||||
const showQualitySelector =
|
||||
!isLivestreamClaim ||
|
||||
(livestreamVideoUrl && (livestreamVideoUrl.includes('/transcode/') || livestreamVideoUrl.includes('cloud.odysee')));
|
||||
|
||||
// initiate keyboard shortcuts
|
||||
const { curried_function } = keyboardShorcuts({
|
||||
|
@ -323,13 +325,13 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
return vjs;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (showQualitySelector) {
|
||||
// Add quality selector to player
|
||||
const player = playerRef.current;
|
||||
if (player) player.hlsQualitySelector({ displayCurrentQuality: true });
|
||||
}
|
||||
}, [showQualitySelector]);
|
||||
// useEffect(() => {
|
||||
// if (showQualitySelector) {
|
||||
// // Add quality selector to player
|
||||
// const player = playerRef.current;
|
||||
// if (player) player.hlsQualitySelector({ displayCurrentQuality: true });
|
||||
// }
|
||||
// }, [showQualitySelector]);
|
||||
|
||||
/** instantiate videoJS and dispose of it when done with code **/
|
||||
// This lifecycle hook is only called once (on mount), or when `isAudio` or `source` changes.
|
||||
|
|
|
@ -9,9 +9,9 @@ export const LIVESTREAM_RTMP_URL = 'rtmp://stream.odysee.com/live';
|
|||
export const LIVESTREAM_KILL = 'https://api.stream.odysee.com/stream/kill';
|
||||
|
||||
// new livestream endpoints (old can be removed at some future point)
|
||||
// export const NEW_LIVESTREAM_RTMP_URL = 'rtmp://publish.odysee.live/live';
|
||||
// export const NEW_LIVESTREAM_REPLAY_API = 'https://api.odysee.live/replays/list';
|
||||
// export const NEW_LIVESTREAM_LIVE_API = 'https://api.odysee.live/livestream/is_live';
|
||||
export const NEW_LIVESTREAM_RTMP_URL = 'rtmp://publish.odysee.live/live';
|
||||
export const NEW_LIVESTREAM_REPLAY_API = 'https://api.odysee.live/replays/list';
|
||||
export const NEW_LIVESTREAM_LIVE_API = 'https://api.odysee.live/livestream';
|
||||
|
||||
export const MAX_LIVESTREAM_COMMENTS = 50;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as ACTIONS from 'constants/action_types';
|
||||
import { getAuthToken } from 'util/saved-passwords';
|
||||
import { doNotificationList } from 'redux/actions/notifications';
|
||||
import { doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
||||
import { SOCKETY_SERVER_API } from 'config';
|
||||
|
||||
const NOTIFICATION_WS_URL = `${SOCKETY_SERVER_API}/internal?id=`;
|
||||
|
@ -145,6 +146,13 @@ export const doCommentSocketConnect = (uri, channelName, claimId, subCategory) =
|
|||
data: { comment_id },
|
||||
});
|
||||
}
|
||||
|
||||
if (response.type === 'livestream') {
|
||||
const { channel_id } = response.data;
|
||||
|
||||
// update the live status for the stream
|
||||
dispatch(doFetchChannelLiveStatus(channel_id));
|
||||
}
|
||||
},
|
||||
'comment'
|
||||
);
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
// @flow
|
||||
import { LIVESTREAM_LIVE_API, LIVESTREAM_KILL, LIVESTREAM_STARTS_SOON_BUFFER } from 'constants/livestream';
|
||||
import {
|
||||
LIVESTREAM_LIVE_API,
|
||||
NEW_LIVESTREAM_LIVE_API,
|
||||
LIVESTREAM_KILL,
|
||||
LIVESTREAM_STARTS_SOON_BUFFER,
|
||||
} from 'constants/livestream';
|
||||
import { toHex } from 'util/hex';
|
||||
import Lbry from 'lbry';
|
||||
import moment from 'moment';
|
||||
|
@ -96,19 +101,34 @@ export const fetchLiveChannels = async (): Promise<LivestreamInfo> => {
|
|||
* @returns {Promise<{channelStatus: string}|{channelData: LivestreamInfo, channelStatus: string}>}
|
||||
*/
|
||||
export const fetchLiveChannel = async (channelId: string): Promise<LiveChannelStatus> => {
|
||||
const newApiEndpoint = LIVESTREAM_LIVE_API;
|
||||
const newApiResponse = await fetch(`${newApiEndpoint}/${channelId}?1`);
|
||||
const newApiEndpoint = NEW_LIVESTREAM_LIVE_API;
|
||||
const oldApiEndpoint = LIVESTREAM_LIVE_API;
|
||||
const newApiResponse = await fetch(`${newApiEndpoint}/is_live?channel_claim_id=${channelId}`);
|
||||
const newApiData = (await newApiResponse.json()).data;
|
||||
const isLive = newApiData.live;
|
||||
|
||||
let isLive = newApiData.Live;
|
||||
let translatedData = [];
|
||||
// transform data to old API standard
|
||||
const translatedData = {
|
||||
url: newApiData.url,
|
||||
type: 'application/x-mpegurl',
|
||||
viewCount: newApiData.viewCount,
|
||||
claimId: newApiData.claimId,
|
||||
timestamp: newApiData.timestamp,
|
||||
};
|
||||
if (isLive) {
|
||||
translatedData = {
|
||||
url: newApiData.VideoURL,
|
||||
type: 'application/x-mpegurl',
|
||||
viewCount: newApiData.ViewerCount,
|
||||
claimId: newApiData.ChannelClaimID,
|
||||
timestamp: newApiData.Start,
|
||||
};
|
||||
} else {
|
||||
const oldApiResponse = await fetch(`${oldApiEndpoint}/${channelId}`);
|
||||
const oldApiData = (await oldApiResponse.json()).data;
|
||||
|
||||
isLive = oldApiData.live;
|
||||
translatedData = {
|
||||
url: oldApiData.url,
|
||||
type: 'application/x-mpegurl',
|
||||
viewCount: oldApiData.viewCount,
|
||||
claimId: oldApiData.claimId,
|
||||
timestamp: oldApiData.timestamp,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
if (isLive === false) {
|
||||
|
|
Loading…
Reference in a new issue