# Source

Media source state and actions for the player store

Tracks the current media source and readiness.

## Import

```ts
import { sourceFeature } from '@videojs/html';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://videojs.org/docs/framework/html/guides/presets) include this feature.

## API Reference

### State

| Property | Type | Description |
| --- | --- | --- |
| `source` | `string \| null` | Current media source URL (null if none). |
| `canPlay` | `boolean` | Whether enough data is loaded to begin playback. |

### Actions

| Action | Type | Description |
| --- | --- | --- |
| `loadSource` | `(src: string) => string` | Load a new media source. Returns the new source URL. |

### Selector

Pass `selectSource` to [`PlayerController`](https://videojs.org/docs/framework/html/reference/api/player-controller) to subscribe to source state. Returns `undefined` if the source feature is not configured.

**source-info.ts**

```ts
import { createPlayer, UIElement, selectSource } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';

const { PlayerController } = createPlayer({ features: videoFeatures });

class SourceInfo extends UIElement {
  readonly #source = new PlayerController(this, selectSource);
}
```

---

HTML documentation: https://videojs.org/docs/framework/html/llms.txt
All documentation: https://videojs.org/llms.txt
