-
Notifications
You must be signed in to change notification settings - Fork 20
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: video player #29
Draft
account0123
wants to merge
10
commits into
upryzing:main
Choose a base branch
from
account0123:media
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9fc6192
feat: add video player in message
account0123 39cc816
feat: add video player in modal
account0123 e86c9e9
nit: improved code readability
account0123 379cc06
feat: Audio player (beta)
account0123 0e9fec1
feat: Background audio service
account0123 41c75d5
nit: prettier
account0123 618f3f3
nit: AudioPlayer as observer
account0123 234519d
Merge branch 'master' into media
account0123 5e857bf
fix: track player + audio player removed
account0123 c3e0c5f
Merge branch 'master' into media
account0123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {useState, useRef, useEffect} from 'react'; | ||
import {Dimensions, Pressable} from 'react-native'; | ||
import {observer} from 'mobx-react-lite'; | ||
|
||
import {Attachment} from 'revolt.js'; | ||
import VideoPlayer from 'react-native-video-controls'; | ||
|
||
import {app, client} from '../../../Generic'; | ||
|
||
export const VideoEmbed = observer( | ||
({attachment: a}: {attachment: Attachment}) => { | ||
const [expand, setExpand] = useState(false); | ||
const video = useRef(null); | ||
let width = a.metadata.width, | ||
height = a.metadata.height; | ||
if (width > Dimensions.get('screen').width - 75) { | ||
const sizeFactor = (Dimensions.get('screen').width - 75) / width; | ||
width = width * sizeFactor; | ||
height = height * sizeFactor; | ||
} | ||
const uri = client.generateFileURL(a); | ||
useEffect(() => { | ||
expand && | ||
video.current && | ||
video.current.setState({isFullscreen: false, paused: true}), | ||
setExpand(false); | ||
}, [expand]); | ||
return ( | ||
<Pressable> | ||
<VideoPlayer | ||
ref={ref => (video.current = ref)} | ||
source={{uri}} | ||
tapAnywhereToPause | ||
disableBack | ||
onEnterFullscreen={() => { | ||
app.openVideo(uri, video.current); | ||
setExpand(false); | ||
}} | ||
onLoad={() => { | ||
video.current && video.current.setState({paused: true}); | ||
}} | ||
style={{ | ||
width: width, | ||
height: height, | ||
marginBottom: 4, | ||
borderRadius: 3, | ||
}} | ||
/> | ||
</Pressable> | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {ToastAndroid} from 'react-native'; | ||
import TrackPlayer, {Event} from 'react-native-track-player'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
||
import {differenceInMinutes} from 'date-fns'; | ||
import {Channel, Message} from 'revolt.js'; | ||
|
@@ -185,4 +186,4 @@ export async function fetchMessages( | |
|
||
export function showToast(badgeName: string) { | ||
ToastAndroid.show(badgeName, ToastAndroid.SHORT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the splitting of this PR, this needs to be removed