Skip to content
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

feat: hls player ui for mweb #2446

Merged
merged 27 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4f7581f
feat: hls player ui for mweb
amar-1995 Jan 21, 2024
cc4c046
fix: added leave icon
amar-1995 Feb 5, 2024
877ccc8
fix: added hls mweb file structure
amar-1995 Feb 6, 2024
8c0b209
fix: remove footer and added chat open for portrait mode
amar-1995 Feb 6, 2024
b103a92
fix: size of portrait chat box
amar-1995 Feb 7, 2024
9f6374a
fix: added proper chat view
amar-1995 Feb 11, 2024
5cb7cb2
fix: add no chat view
amar-1995 Feb 11, 2024
2f6bf6b
fix: merge with main
amar-1995 Feb 12, 2024
5aeab87
fix: remove separate mweb stream file
amar-1995 Feb 13, 2024
96f008d
fix: cleanup and handle desktop view
amar-1995 Feb 13, 2024
2dbd5e3
fix: autofocus
amar-1995 Feb 13, 2024
22ee5a5
fix: autofocus chat for landscape
amar-1995 Feb 13, 2024
3724d6a
fix: hls player context
amar-1995 Feb 13, 2024
64a4490
fix: design parity
amar-1995 Feb 18, 2024
e8bff4e
fix: updated parity and pr comments
amar-1995 Feb 19, 2024
46d1cae
fix: quality file to tsx
amar-1995 Feb 19, 2024
786a07d
fix: negative timer for video
amar-1995 Feb 19, 2024
7b1a7c9
fix: added playlist type
amar-1995 Feb 20, 2024
177e6bb
fix: touch handler
amar-1995 Feb 21, 2024
d070729
fix: merge with main
amar-1995 Feb 21, 2024
91419e9
fix: bug fixes
amar-1995 Feb 26, 2024
540255d
fix: object fit contain
amar-1995 Feb 26, 2024
3fc6c0e
fix: cleanup
amar-1995 Feb 27, 2024
ae1f4e4
fix: remove qa room
amar-1995 Feb 27, 2024
5da6d47
fix: added types
amar-1995 Feb 27, 2024
40d2d94
fix: added playlist button
amar-1995 Feb 27, 2024
d456427
fix: pr comment
amar-1995 Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions examples/prebuilt-react-integration/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ export default function App() {
const roomCode = getRoomCodeFromUrl();

return (
<HMSPrebuilt roomCode={roomCode}/>
)
<HMSPrebuilt
roomCode={roomCode}
options={{
endpoints: {
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
tokenByRoomCode: 'https://auth-nonprod.100ms.live/v2/token',
roomLayout: 'https://api-nonprod.100ms.live/v2/layouts/ui',
init: 'https://qa-in2-ipv6.100ms.live/init',
},
}}
/>
);
}


3 changes: 3 additions & 0 deletions examples/prebuilt-react-integration/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ export default defineConfig({
define: {
'process.env': {},
},
optimizeDeps: {
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
exclude: ['lodash'],
},
});
14 changes: 14 additions & 0 deletions packages/roomkit-react/src/Prebuilt/common/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { useMedia } from 'react-use';
import { JoinForm_JoinBtnType } from '@100mslive/types-prebuilt/elements/join_form';
import {
selectAvailableRoleNames,
Expand All @@ -10,6 +11,7 @@ import {
useHMSStore,
useHMSVanillaStore,
} from '@100mslive/react-sdk';
import { config } from '../../Theme';
import { useRoomLayout } from '../provider/roomLayoutProvider';
import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
import { CHAT_SELECTOR } from './constants';
Expand Down Expand Up @@ -100,3 +102,15 @@ export const useParticipants = (params?: { metadata?: { isHandRaised?: boolean }
}
return { participants: participantList, isConnected, peerCount, rolesWithParticipants };
};

export const useLandscapeHLSStream = () => {
const isLandscape = useMedia(config.media.ls);
const { screenType } = useRoomLayoutConferencingScreen();
return isLandscape && screenType === 'hls_live_streaming';
};

export const useMobileHLSStream = () => {
const isMobile = useMedia(config.media.md);
const { screenType } = useRoomLayoutConferencingScreen();
return isMobile && screenType === 'hls_live_streaming';
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'reac
import { useMedia } from 'react-use';
import data from '@emoji-mart/data';
import Picker from '@emoji-mart/react';
import { HMSException, selectLocalPeer, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
import { HMSException, selectLocalPeer, useAVToggle, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
import { EmojiIcon, PauseCircleIcon, SendIcon, VerticalMenuIcon } from '@100mslive/react-icons';
import { Box, config as cssConfig, Flex, IconButton as BaseIconButton, Popover, styled, Text } from '../../..';
import { IconButton } from '../../../IconButton';
import { MoreSettings } from '../MoreSettings/MoreSettings';
// @ts-ignore: No implicit Any
import { RaiseHand } from '../RaiseHand';
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore
import { ToastManager } from '../Toast/ToastManager';
import { ChatSelectorContainer } from './ChatSelectorContainer';
Expand All @@ -17,7 +20,7 @@ import { useSetSubscribedChatSelector, useSubscribeChatSelector } from '../AppDa
import { useIsPeerBlacklisted } from '../hooks/useChatBlacklist';
// @ts-ignore
import { useEmojiPickerStyles } from './useEmojiPickerStyles';
import { useDefaultChatSelection } from '../../common/hooks';
import { useDefaultChatSelection, useLandscapeHLSStream } from '../../common/hooks';
import { CHAT_SELECTOR, SESSION_STORE_KEY } from '../../common/constants';

const TextArea = styled('textarea', {
Expand Down Expand Up @@ -77,7 +80,8 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
const inputRef = useRef<HTMLTextAreaElement>(null);
const [draftMessage, setDraftMessage] = useChatDraftMessage();
const isMobile = useMedia(cssConfig.media.md);
const { elements } = useRoomLayoutConferencingScreen();
const isLandscape = useMedia(cssConfig.media.ls);
const { elements, screenType } = useRoomLayoutConferencingScreen();
const message_placeholder = elements?.chat?.message_placeholder || 'Send a message';
const localPeer = useHMSStore(selectLocalPeer);
const isOverlayChat = elements?.chat?.is_overlay;
Expand All @@ -87,6 +91,10 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
const defaultSelection = useDefaultChatSelection();
const selection = selectedPeer.name || selectedRole || defaultSelection;
const isLocalPeerBlacklisted = useIsPeerBlacklisted({ local: true });
const { toggleAudio, toggleVideo } = useAVToggle();
const noAVPermissions = !(toggleAudio || toggleVideo);
const isMwebHLSStream = screenType === 'hls_live_streaming' && (isMobile || isLandscape);
const isLandscapeHLSStream = useLandscapeHLSStream();

useEffect(() => {
if (!selectedPeer.id && !selectedRole && !['Everyone', ''].includes(defaultSelection)) {
Expand Down Expand Up @@ -198,7 +206,7 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
position: 'relative',
py: '$6',
pl: '$8',
flexGrow: 1,
flexGrow: `${isMwebHLSStream ? 1 : 0}`,
r: '$1',
'@md': {
minHeight: 'unset',
Expand Down Expand Up @@ -234,7 +242,7 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
onCut={e => e.stopPropagation()}
onCopy={e => e.stopPropagation()}
/>
{!isMobile ? (
{!isMobile && !isLandscapeHLSStream ? (
<EmojiPicker
onSelect={emoji => {
if (inputRef.current) {
Expand All @@ -257,6 +265,17 @@ export const ChatFooter = ({ onSend, children }: { onSend: (count: number) => vo
<SendIcon />
</BaseIconButton>
</Flex>
{isMwebHLSStream && (
<Flex
css={{
alignItems: 'center',
}}
gap="1"
>
{noAVPermissions ? <RaiseHand /> : null}
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
<MoreSettings elements={elements} screenType={screenType} />
</Flex>
)}
</Flex>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import React, { useEffect, useRef, useState } from 'react';
import { useMedia } from 'react-use';
import { DefaultConferencingScreen_Elements } from '@100mslive/types-prebuilt';
import {
HMSRoomState,
selectAppData,
selectIsConnectedToRoom,
selectRoomState,
useAVToggle,
useHMSActions,
useHMSStore,
} from '@100mslive/react-sdk';
import { Footer } from './Footer/Footer';
import { LeaveRoom } from './Leave/LeaveRoom';
import { MoreSettings } from './MoreSettings/MoreSettings';
import { HLSFailureModal } from './Notifications/HLSFailureModal';
// @ts-ignore: No implicit Any
import { ActivatedPIP } from './PIP/PIPComponent';
// @ts-ignore: No implicit Any
import { PictureInPicture } from './PIP/PIPManager';
import { RoleChangeRequestModal } from './RoleChangeRequest/RoleChangeRequestModal';
import { Box, Flex } from '../../Layout';
import { config } from '../../Theme';
import { useHMSPrebuiltContext } from '../AppContext';
import { VideoStreamingSection } from '../layouts/VideoStreamingSection';
// @ts-ignore: No implicit Any
import FullPageProgress from './FullPageProgress';
import { Header } from './Header';
import { PreviousRoleInMetadata } from './PreviousRoleInMetadata';
// @ts-ignore: No implicit Any
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
import { RaiseHand } from './RaiseHand';
import {
useRoomLayoutConferencingScreen,
useRoomLayoutPreviewScreen,
Expand All @@ -46,12 +53,19 @@ export const ConferenceScreen = () => {
const isMobileDevice = isAndroid || isIOS || isIPadOS;
const dropdownListRef = useRef<string[]>();
const [isHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted);

const { toggleAudio, toggleVideo } = useAVToggle();
const noAVPermissions = !(toggleAudio || toggleVideo);
const showChat = !!screenProps.elements?.chat;
const toggleControls = () => {
if (dropdownListRef.current?.length === 0 && isMobileDevice) {
setHideControls(value => !value);
}
};
const autoRoomJoined = useRef(isPreviewScreenEnabled);
const isMobile = useMedia(config.media.md);
const isLandscape = useMedia(config.media.ls);
const isMwebHLSStream = screenProps.screenType === 'hls_live_streaming' && (isMobile || isLandscape);

useEffect(() => {
let timeout: undefined | ReturnType<typeof setTimeout>;
Expand Down Expand Up @@ -112,7 +126,7 @@ export const ConferenceScreen = () => {
</Box>
) : null}
<Flex css={{ size: '100%', overflow: 'hidden' }} direction="column">
{!screenProps.hideSections.includes('header') && (
{!screenProps.hideSections.includes('header') && !isMwebHLSStream && (
amar-1995 marked this conversation as resolved.
Show resolved Hide resolved
<Box
ref={headerRef}
css={{
Expand All @@ -128,6 +142,11 @@ export const ConferenceScreen = () => {
<Header />
</Box>
)}
{isMwebHLSStream && (
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
<Flex align="center" gap="2" css={{ position: 'absolute', left: '$4', top: '$4', zIndex: 1 }}>
<LeaveRoom screenType={screenProps.screenType} />
</Flex>
)}
<Box
css={{
w: '100%',
Expand All @@ -154,7 +173,7 @@ export const ConferenceScreen = () => {
/>
) : null}
</Box>
{!screenProps.hideSections.includes('footer') && screenProps.elements && (
{!screenProps.hideSections.includes('footer') && screenProps.elements && !isMwebHLSStream && (
<Box
ref={footerRef}
css={{
Expand All @@ -173,6 +192,20 @@ export const ConferenceScreen = () => {
<Footer elements={screenProps.elements} screenType={screenProps.screenType} />
</Box>
)}
{isMwebHLSStream && !showChat && (
<Flex
css={{
alignItems: 'center',
pr: '$4',
pb: '$4',
}}
justify="end"
gap="1"
>
{noAVPermissions ? <RaiseHand /> : null}
<MoreSettings elements={screenProps.elements} screenType={screenProps.screenType} />
</Flex>
)}
<RoleChangeRequestModal />
<HLSFailureModal />
<ActivatedPIP />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex, styled } from '../../../';
import { Flex, styled } from '../../..';

export const VideoControls = styled(Flex, {
justifyContent: 'center',
Expand Down
Loading
Loading