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

Docs: Add Audio Player Readme #69406

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
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
58 changes: 58 additions & 0 deletions packages/block-editor/src/components/audio-player/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
### Audio Player Component

The `audio-player` component is a React Native component used within the WordPress Gutenberg mobile editor. It provides an interface for embedding and playing audio files.

---

#### Installation
This component is part of the WordPress Gutenberg repository and does not require separate installation. Ensure your project is set up with Gutenberg mobile dependencies.

---

#### Usage

```jsx
import AudioPlayer from './path/to/audio-player';

<AudioPlayer
isUploadInProgress={false}
isUploadFailed={false}
attributes={{ id: 1, src: 'https://example.com/audio.mp3' }}
isSelected={true}
/>
```

---

#### Props

| Prop | Type | Description |
|---------------------|----------|-------------|
| `isUploadInProgress` | `boolean` | Indicates whether an audio file is currently being uploaded. |
| `isUploadFailed` | `boolean` | Indicates whether the audio file upload has failed. |
| `attributes` | `object` | Contains audio metadata including `id` and `src` URL of the file. |
| `isSelected` | `boolean` | Indicates whether the component is selected in the editor. |

---

#### Features
- Supports opening audio files via linking (`Linking.openURL`).
- Displays upload progress and failure states.
- Provides an option to cancel or retry failed uploads.
- Uses `react-native-video` for playback support on iOS.
- Handles UI appearance according to the current editor color scheme.

---

#### Platform Considerations
- On **iOS**, the component uses `react-native-video` for playback.
- On **Android**, audio files are opened via the default audio player application.

---

#### Related Components
- `Icon` from `@wordpress/components` for displaying audio icons.
- `useEditorColorScheme` from `../global-styles/use-global-styles-context` for adaptive theming.
- `requestImageFailedRetryDialog` and `requestImageUploadCancelDialog` from `@wordpress/react-native-bridge` for handling upload dialogs.


Loading