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
Lite: Make the Examples component display media files using pseudo HTTP requests to the Wasm server #5627
Merged
+284
−62
Merged
Lite: Make the Examples component display media files using pseudo HTTP requests to the Wasm server #5627
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3c349f0
Create a Wasm-compatible <Image> component in @gradio/lite and use it…
whitphx 8f5de8a
add changeset
gradio-pr-bot 60655b1
Fix Image styling
whitphx 506c490
Move js/wasm/svelte/Image.svelte -> js/image/static/Image.svelte
whitphx 7013f32
Shorten CSS class name
whitphx e37c8e8
Create Wasm-compatible video components
whitphx dfe571a
add changeset
gradio-pr-bot 8b650d8
Move the Wasm-compatible `Image` from `static` to `shared`
whitphx d7a99e0
Create Wasm-compatible audio components
whitphx f53a85e
Fix `resolve_wasm_src()` to return the passed `src` as-is when the UR…
whitphx 1a8c688
add changeset
gradio-pr-bot ee1dd20
Fix `resolve_wasm_src()`
whitphx 25e43c7
Merge branch 'main' into wasm-example-media-files
whitphx 0aaa445
Merge branch 'main' into wasm-example-media-files
whitphx File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@gradio/app": minor | ||
"@gradio/audio": minor | ||
"@gradio/image": minor | ||
"@gradio/video": minor | ||
"@gradio/wasm": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat:Lite: Make the Examples component display media files using pseudo HTTP requests to the Wasm server |
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,33 @@ | ||
<script lang="ts"> | ||
import type { HTMLAudioAttributes } from "svelte/elements"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { loaded, type LoadedParams } from "../shared/utils"; | ||
import { resolve_wasm_src } from "@gradio/wasm/svelte"; | ||
|
||
export let src: HTMLAudioAttributes["src"] = undefined; | ||
|
||
export let autoplay: LoadedParams["autoplay"] = undefined; | ||
export let crop_values: LoadedParams["crop_values"] = undefined; | ||
export let controls: HTMLAudioAttributes["controls"] = undefined; | ||
export let preload: HTMLAudioAttributes["preload"] = undefined; | ||
|
||
export let node: HTMLAudioElement | undefined = undefined; | ||
|
||
const dispatch = createEventDispatcher(); | ||
</script> | ||
|
||
{#await resolve_wasm_src(src) then resolved_src} | ||
<audio | ||
src={resolved_src} | ||
{controls} | ||
{preload} | ||
on:play={dispatch.bind(null, "play")} | ||
on:pause={dispatch.bind(null, "pause")} | ||
on:ended={dispatch.bind(null, "ended")} | ||
bind:this={node} | ||
use:loaded={{ autoplay, crop_values }} | ||
data-testid={$$props["data-testid"]} | ||
/> | ||
{:catch error} | ||
<p style="color: red;">{error.message}</p> | ||
{/await} |
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,22 @@ | ||
<script lang="ts"> | ||
import type { HTMLImgAttributes } from "svelte/elements"; | ||
type $$Props = HTMLImgAttributes; | ||
|
||
import { resolve_wasm_src } from "@gradio/wasm/svelte"; | ||
|
||
export let src: HTMLImgAttributes["src"] = undefined; | ||
</script> | ||
|
||
{#await resolve_wasm_src(src) then resolved_src} | ||
<!-- svelte-ignore a11y-missing-attribute --> | ||
<img src={resolved_src} {...$$restProps} /> | ||
{:catch error} | ||
<p style="color: red;">{error.message}</p> | ||
{/await} | ||
|
||
<style> | ||
img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
} | ||
</style> |
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
Oops, something went wrong.
Oops, something went wrong.
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.
This is the only media component where the interactive version has been changed rather than the example. Is there a reason for that?
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.
It's just because of the codebase structure.
In the case of Audio,
example/Audio.svelte
doesn't have the<audio />
tag as it only shows the example file name, and modifyinginteractive/Audio.svelte
was needed to make audio apps work instead.In turn, for example in the case of Video, all Video components uses
shared/Player.svelte
under the hood, so I just modified it.FYI, I benchmarked the following 3 spaces to make sure the pair of a media input component and
gr.Examples()
works.So there might be missing parts. Will catch them in another PR if found.