# SEmbeddedVideo

**成员** 20

|      |                                           |                                                           |
| ---- | ----------------------------------------- | --------------------------------------------------------- |
| 函数 | [OnStateChange](#onstatechange)           | –                                                         |
| 函数 | [Play](#play)                             | If URL is set, plays the video                            |
| 函数 | [Stop](#stop)                             | Stops the playback                                        |
| 函数 | [Pause](#pause)                           | Pauses currently played video                             |
| 函数 | [Resume](#resume)                         | If the video is currently paused, it will resume playback |
| 函数 | [SynchorizeUrl](#synchorizeurl)           | Synchorize current video URL                              |
| 函数 | [ClearRenderTexture](#clearrendertexture) | Clears the Render Texture                                 |
| 属性 | [State](#state)                           | The state player is currently in.                         |
| 属性 | [URL](#url)                               | Current URL set for this Player.                          |
| 属性 | [AudioSource](#audiosource)               | Current AudioSource                                       |
| 属性 | [OutputTexture](#outputtexture)           | –                                                         |
| 属性 | [Texture](#texture)                       | Texture which the player uses to display the video.       |
| 属性 | [Time](#time)                             | Current player time.                                      |
| 属性 | [Position](#position)                     | Current Video Frame Position                              |
| 属性 | [UniqueName](#uniquename)                 | –                                                         |
| 属性 | [VideoLength](#videolength)               | Get the length of the video                               |
| 属性 | [Loop](#loop)                             | Whether video is set to loop or not                       |
| 属性 | [FrameCount](#framecount)                 | Returns the frame count of the video                      |
| 属性 | [IsPlaying](#isplaying)                   | Returns whether the video is playing or not               |
| 属性 | [GameObject](#gameobject)                 | –                                                         |

## 函数

### OnStateChange

void OnStateChange(Closure e)

参数

| 名称 | 类型    | 默认值 |
| ---- | ------- | ------ |
| e    | Closure | –      |

返回值

`void`

示例

**Lua**

```lua
function stateChangeFunction(EmbeddedVideo, oldState, newState)
--what happens on state change
end

Space.Host.ExecutingObject.EmbeddedVideo.OnStageChange(stateChangeFunction)

```

**Lua**

```lua
--get embedded video component on your video player 
video = Space.Scene.Find("VidepPlayer").EmbeddedVideo
function GetClosure()
return function (a,b,c)
log(a.URL..b..c)
end
end
video.OnStateChange(GetClosure())
video.Pause()

```

### Play

void Play()

If URL is set, plays the video

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.Play()

```

### Stop

void Stop()

Stops the playback

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.Stop()

```

### Pause

void Pause()

Pauses currently played video

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.Pause()

```

### Resume

void Resume()

If the video is currently paused, it will resume playback

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.Resume()

```

### SynchorizeUrl

void SynchorizeUrl()

Synchorize current video URL

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.SynchorizeUrl()

```

### ClearRenderTexture

void ClearRenderTexture()

Clears the Render Texture

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.EmbeddedVideo.ClearRenderTexture()

```

## 属性

### State

[SEmbeddedVideoState](/docs/zh-Hans/scripting/client-scripting-api-reference/components/sembeddedvideo.md) State {get; }

The state player is currently in. You can track state changes through StateChangeEvent.

示例

**Lua**

```lua
 CurrentVideoState = Space.Host.ExecutingObject.EmbeddedVideo.State

```

### URL

string URL {get; set; }

Current URL set for this Player.

示例

**Lua**

```lua
CurrentURL = Space.Host.ExecutingObject.EmbeddedVideo.URL

```

### AudioSource

[SAudioSource](/docs/zh-Hans/scripting/client-scripting-api-reference/components/saudiosource.md) AudioSource {get; set; }

Current AudioSource

示例

**Lua**

```lua
CurrentAudioSource = Space.Host.ExecutingObject.EmbeddedVideo.AudioSource

```

### OutputTexture

[SResource](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) OutputTexture {get; }

示例

**Lua**

```lua
OutputTexture = Space.Host.ExecutingObject.EmbeddedVideo.OutputTexture

```

### Texture

[SResource](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) Texture {get; }

Texture which the player uses to display the video.

示例

**Lua**

```lua
 Texture = Space.Host.ExecutingObject.EmbeddedVideo.Texture

```

### Time

double Time {get; set; }

Current player time. Can be set to move the 'playhead' to the specific position.

示例

**Lua**

```lua
Time = Space.Host.ExecutingObject.EmbeddedVideo.Time

```

### Position

long Position {get; }

Current Video Frame Position

示例

**Lua**

```lua
Position = Space.Host.ExecutingObject.EmbeddedVideo.Position

```

### UniqueName

string UniqueName {get; }

示例

**Lua**

```lua
UniqueName = Space.Host.ExecutingObject.EmbeddedVideo.UniqueName

```

### VideoLength

double VideoLength {get; }

Get the length of the video

示例

**Lua**

```lua
VideoLength = Space.Host.ExecutingObject.EmbeddedVideo.VideoLength

```

### Loop

bool Loop {get; set; }

Whether video is set to loop or not

示例

**Lua**

```lua
 Space.Host.ExecutingObject.EmbeddedVideo.Loop  = true

```

### FrameCount

int FrameCount {get; }

Returns the frame count of the video

示例

**Lua**

```lua
FrameCount = Space.Host.ExecutingObject.EmbeddedVideo.FrameCount

```

### IsPlaying

bool IsPlaying {get; }

Returns whether the video is playing or not

示例

**Lua**

```lua
IsPlaying = Space.Host.ExecutingObject.EmbeddedVideo.IsPlaying

```

### GameObject

[SGameObject](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

示例

**Lua**

```lua
theGameObject = Space.Host.ExecutingObject.EmbeddedVideo.GameObject

```
