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 playerServerRef = useRef();
|
||||||
|
|
||||||
const { url: livestreamVideoUrl } = activeLivestreamForChannel || {};
|
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
|
// initiate keyboard shortcuts
|
||||||
const { curried_function } = keyboardShorcuts({
|
const { curried_function } = keyboardShorcuts({
|
||||||
|
@ -323,13 +325,13 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
return vjs;
|
return vjs;
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (showQualitySelector) {
|
// if (showQualitySelector) {
|
||||||
// Add quality selector to player
|
// // Add quality selector to player
|
||||||
const player = playerRef.current;
|
// const player = playerRef.current;
|
||||||
if (player) player.hlsQualitySelector({ displayCurrentQuality: true });
|
// if (player) player.hlsQualitySelector({ displayCurrentQuality: true });
|
||||||
}
|
// }
|
||||||
}, [showQualitySelector]);
|
// }, [showQualitySelector]);
|
||||||
|
|
||||||
/** instantiate videoJS and dispose of it when done with code **/
|
/** 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.
|
// 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';
|
export const LIVESTREAM_KILL = 'https://api.stream.odysee.com/stream/kill';
|
||||||
|
|
||||||
// new livestream endpoints (old can be removed at some future point)
|
// 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_RTMP_URL = 'rtmp://publish.odysee.live/live';
|
||||||
// export const NEW_LIVESTREAM_REPLAY_API = 'https://api.odysee.live/replays/list';
|
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_LIVE_API = 'https://api.odysee.live/livestream';
|
||||||
|
|
||||||
export const MAX_LIVESTREAM_COMMENTS = 50;
|
export const MAX_LIVESTREAM_COMMENTS = 50;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { getAuthToken } from 'util/saved-passwords';
|
import { getAuthToken } from 'util/saved-passwords';
|
||||||
import { doNotificationList } from 'redux/actions/notifications';
|
import { doNotificationList } from 'redux/actions/notifications';
|
||||||
|
import { doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
||||||
import { SOCKETY_SERVER_API } from 'config';
|
import { SOCKETY_SERVER_API } from 'config';
|
||||||
|
|
||||||
const NOTIFICATION_WS_URL = `${SOCKETY_SERVER_API}/internal?id=`;
|
const NOTIFICATION_WS_URL = `${SOCKETY_SERVER_API}/internal?id=`;
|
||||||
|
@ -145,6 +146,13 @@ export const doCommentSocketConnect = (uri, channelName, claimId, subCategory) =
|
||||||
data: { comment_id },
|
data: { comment_id },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.type === 'livestream') {
|
||||||
|
const { channel_id } = response.data;
|
||||||
|
|
||||||
|
// update the live status for the stream
|
||||||
|
dispatch(doFetchChannelLiveStatus(channel_id));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'comment'
|
'comment'
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
// @flow
|
// @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 { toHex } from 'util/hex';
|
||||||
import Lbry from 'lbry';
|
import Lbry from 'lbry';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -96,19 +101,34 @@ export const fetchLiveChannels = async (): Promise<LivestreamInfo> => {
|
||||||
* @returns {Promise<{channelStatus: string}|{channelData: LivestreamInfo, channelStatus: string}>}
|
* @returns {Promise<{channelStatus: string}|{channelData: LivestreamInfo, channelStatus: string}>}
|
||||||
*/
|
*/
|
||||||
export const fetchLiveChannel = async (channelId: string): Promise<LiveChannelStatus> => {
|
export const fetchLiveChannel = async (channelId: string): Promise<LiveChannelStatus> => {
|
||||||
const newApiEndpoint = LIVESTREAM_LIVE_API;
|
const newApiEndpoint = NEW_LIVESTREAM_LIVE_API;
|
||||||
const newApiResponse = await fetch(`${newApiEndpoint}/${channelId}?1`);
|
const oldApiEndpoint = LIVESTREAM_LIVE_API;
|
||||||
|
const newApiResponse = await fetch(`${newApiEndpoint}/is_live?channel_claim_id=${channelId}`);
|
||||||
const newApiData = (await newApiResponse.json()).data;
|
const newApiData = (await newApiResponse.json()).data;
|
||||||
const isLive = newApiData.live;
|
let isLive = newApiData.Live;
|
||||||
|
let translatedData = [];
|
||||||
// transform data to old API standard
|
// transform data to old API standard
|
||||||
const translatedData = {
|
if (isLive) {
|
||||||
url: newApiData.url,
|
translatedData = {
|
||||||
type: 'application/x-mpegurl',
|
url: newApiData.VideoURL,
|
||||||
viewCount: newApiData.viewCount,
|
type: 'application/x-mpegurl',
|
||||||
claimId: newApiData.claimId,
|
viewCount: newApiData.ViewerCount,
|
||||||
timestamp: newApiData.timestamp,
|
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 {
|
try {
|
||||||
if (isLive === false) {
|
if (isLive === false) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue