added video and show literature

This commit is contained in:
tonyrewin 2022-11-27 14:35:27 +03:00
parent d68cb92462
commit 8ad358d749
2 changed files with 26 additions and 15 deletions

View File

@ -13,6 +13,7 @@ import RatingControl from './RatingControl'
import { clsx } from 'clsx' import { clsx } from 'clsx'
import { CommentsTree } from './CommentsTree' import { CommentsTree } from './CommentsTree'
import { useSession } from '../../context/session' import { useSession } from '../../context/session'
import VideoPlayer from './VideoPlayer'
interface ArticleProps { interface ArticleProps {
article: Shout article: Shout
@ -45,9 +46,7 @@ const MediaView = (props: { media: MediaItem; kind: Shout['layout'] }) => {
</div> </div>
</Match> </Match>
<Match when={props.kind === 'video'}> <Match when={props.kind === 'video'}>
<video controls> <VideoPlayer url={props.media.url} />
<source src={props.media.url} />
</video>
</Match> </Match>
</Switch> </Switch>
</> </>

View File

@ -1,12 +1,24 @@
export default (props: { youtubeId?: string; vimeoId?: string; title?: string }) => { import { Show } from 'solid-js'
// TODO: styling
return ( export default (props: { url: string }) => (
<video <>
src={ <Show when={props.url.includes('youtube.com')}>
props.vimeoId <iframe
? `https://vimeo.com/${props.vimeoId}` id="ytplayer"
: `https://youtube.com/?watch=${props.youtubeId}` width="640"
} height="360"
src={`https://www.youtube.com/embed/${props.url.split('watch=').pop()}`}
allowfullscreen
/> />
</Show>
<Show when={props.url.includes('vimeo.com')}>
<iframe
src={'https://player.vimeo.com/video/' + props.url.split('video/').pop()}
width="420"
height="345"
allow="autoplay; fullscreen"
allowfullscreen
/>
</Show>
</>
) )
}