Class VideoPlayerBase
Namespace: Headjack
Fields
audioConf
Declaration
protected VideoPlayerBase.AudioConfig audioConf
Field Value
| Type | Description |
|---|---|
| VideoPlayerBase.AudioConfig |
mapping
Declaration
public VideoPlayerBase.Mapping mapping
Field Value
| Type | Description |
|---|---|
| VideoPlayerBase.Mapping |
MAX_DELAYED_SYNC_MS
Declaration
protected const long MAX_DELAYED_SYNC_MS = 1000L
Field Value
| Type | Description |
|---|---|
| System.Int64 |
MAX_SYNC_DIFF_MS
Declaration
protected const long MAX_SYNC_DIFF_MS = 2500L
Field Value
| Type | Description |
|---|---|
| System.Int64 |
mute_
Declaration
protected bool mute_
Field Value
| Type | Description |
|---|---|
| System.Boolean |
ProjectionMesh
The mesh that displays the video. Mesh type depends on video projection
Declaration
public MeshRenderer ProjectionMesh
Field Value
| Type | Description |
|---|---|
| MeshRenderer |
subtitles
Subtitle class
Declaration
public Subtitles subtitles
Field Value
| Type | Description |
|---|---|
| Subtitles |
SYNCED_DELAY_THRESHOLD_MS
Declaration
protected const long SYNCED_DELAY_THRESHOLD_MS = 8L
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TEXTURE_FLIP_SHADER_KEYWORD
Declaration
protected const string TEXTURE_FLIP_SHADER_KEYWORD = "FORCE_TEXTURE_FLIP"
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
Buffering
True if the videoplayer is buffering
Declaration
public bool Buffering { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | If the videoplayer is buffering |
Examples
//Show buffering icon when buffering
void Update()
{
if(App.Player.Buffering)
{
BufferingObject.SetActive(true);
}else{
BufferingObject.SetActive(false);
}
}
CurrentStatus
The current playback status
Declaration
public VideoPlayerBase.Status CurrentStatus { get; }
Property Value
| Type | Description |
|---|---|
| VideoPlayerBase.Status | True if the video is being streamed right now |
Duration
The total duration of the video
Declaration
public long Duration { get; }
Property Value
| Type | Description |
|---|---|
| System.Int64 | The total duration of the video in milliseconds |
Examples
public float VideoLengthInSeconds()
{
return App.Player.Duration*0.001f;
}
IsPlaying
If the video is being played right now
Declaration
public bool IsPlaying { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | True if the video is being played right now |
Remarks
Note
False on pause
Examples
void Update()
{
//Don't show the crosshair if the video is playing
if(App.Player.IsPlaying)
{
App.ShowCrosshair=false;
}
}
IsStream
Whether the current video is streaming or not
Declaration
public bool IsStream { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | True if the video is being streamed right now |
LastTimestamp
The realtime local timestamp of the latest command/function (e.g PauseAt or PlayAt)
Declaration
public long LastTimestamp { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
LastVideoTime
The video timestamp of the latest command/function (e.g PauseAt or PlayAt)
Declaration
public long LastVideoTime { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
Loop
If this is a looping video
Declaration
public bool Loop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | If the video is currently set to loop |
Examples
public void LoopButtonSwitch()
{
App.Player.Loop=!App.Player.Loop;
}
Mute
If this video is muted
Declaration
public bool Mute { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | If the video is currently muted |
Examples
public void MuteButtonSwitch()
{
App.Player.Mute=!App.Player.Mute;
}
Seek
The video position (0.0 - 1.0)
Declaration
public float Seek { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single | The current position of the video from 0.0 to 1.0 |
Examples
//Change position with Arrow Keys
void Update()
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
App.Player.Seek += 0.05f;
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
App.Player.Seek -= 0.05f;
}
}
SeekMs
The video position in milliseconds
Declaration
public long SeekMs { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int64 | The current position of the video in milliseconds |
Examples
//Change position by 5 seconds with Arrow Keys
void Update()
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
App.Player.SeekMs += 5000;
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
App.Player.SeekMs -= 5000;
}
}
Volume
Videoplayer volume
Declaration
public float Volume { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single | The current volume of the videoplayer |
Examples
//Change volume with Arrow Keys
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
App.Player.Volume += 0.1f;
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
App.Player.Volume -= 0.1f;
}
}
Methods
Clean()
Clean up the video
Declaration
public virtual void Clean()
Examples
public void Release()
{
App.Player.Clean();
}
CreateEyes()
Declaration
protected void CreateEyes()
FocusAt(Int32)
Focus at a certain direction in the video
Declaration
public void FocusAt(int Degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | Degrees | Direction in degrees |
Remarks
Note
You can use this to disable the stereo effect if you want to display an interface
GetAudioConfig()
Gets the audio playing configuration, whether playing audio of video file (internal) and/or playing external (spatial) audio file (external)
Declaration
public VideoPlayerBase.AudioConfig GetAudioConfig()
Returns
| Type | Description |
|---|---|
| VideoPlayerBase.AudioConfig | VideoPlayerBase.AudioConfig struct describing current audio configuration |
Remarks
Note
Use SetAudioConfig(Boolean, Boolean) to change the audio configuration
GetBuffering()
Declaration
protected abstract bool GetBuffering()
Returns
| Type | Description |
|---|---|
| System.Boolean |
GetDuration()
Declaration
protected abstract long GetDuration()
Returns
| Type | Description |
|---|---|
| System.Int64 |
GetIsPlaying()
Declaration
protected abstract bool GetIsPlaying()
Returns
| Type | Description |
|---|---|
| System.Boolean |
GetLoop()
Declaration
protected abstract bool GetLoop()
Returns
| Type | Description |
|---|---|
| System.Boolean |
GetSeek()
Declaration
protected abstract float GetSeek()
Returns
| Type | Description |
|---|---|
| System.Single |
GetSeekMs()
Declaration
protected abstract long GetSeekMs()
Returns
| Type | Description |
|---|---|
| System.Int64 |
GetVideoTexture()
Declaration
public abstract Texture GetVideoTexture()
Returns
| Type | Description |
|---|---|
| Texture |
GetVolume()
Declaration
protected abstract float GetVolume()
Returns
| Type | Description |
|---|---|
| System.Single |
OnDestroy()
Declaration
protected virtual void OnDestroy()
Pause()
Pause the video
Declaration
public virtual void Pause()
Remarks
Note
Will set VideoPlayer.IsPlaying to false
Examples
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
App.Player.Pause();
}
}
PauseAt(Int64)
Pause the video at a specific timestamp NOTE: video is paused on a timecode derived from the realtime timestamp
Declaration
public virtual void PauseAt(long pauseTime)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | pauseTime | Realtime (local) timestamp to pause playback |
PauseResume()
Switch between playing and paused
Declaration
public virtual void PauseResume()
Examples
void Update()
{
//Pause switch
if (Input.GetKeyDown(KeyCode.Space))
{
App.Player.PauseResume();
}
}
Play(String, Boolean, OnEnd, String)
Play a new video
Declaration
public virtual void Play(string FullPath, bool Stream, OnEnd onEnd = null, string FullPathFallback = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | FullPath | Full path to the mp4 file |
| System.Boolean | Stream | Whether to play local video or stream URL |
| OnEnd | onEnd | Will be called when the video is finished |
| System.String | FullPathFallback | deprecated fallback video path, now unused |
Remarks
Note
onEnd overwrites current onEnd
Warning
You need a full path to the mp4 file. To play videos from the server use Play(String, Boolean, Boolean, OnEnd)
PlayAt(Int64, Int64)
Start playing the currently loaded video from a specific time, starting on a specific timestamp
Declaration
public virtual void PlayAt(long playTime, long videoTime = -1L)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | playTime | Realtime (local) timestamp to start playing |
| System.Int64 | videoTime | Video timecode to start playing from |
Prepare(String, Boolean, OnEnd, String, Int64)
Declaration
public virtual void Prepare(string FullPath, bool Stream, OnEnd onEnd = null, string FullPathFallback = null, long VideoTime = 0L)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | FullPath | |
| System.Boolean | Stream | |
| OnEnd | onEnd | |
| System.String | FullPathFallback | |
| System.Int64 | VideoTime |
Resume()
Resume the video
Declaration
public virtual void Resume()
Remarks
Note
Will set VideoPlayer.IsPlaying to true
Examples
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
App.Player.Resume();
}
}
SeekTo(Int64, Int64)
Declaration
public virtual void SeekTo(long seekTime, long videoTime)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | seekTime | |
| System.Int64 | videoTime |
SetAudioConfig(Boolean, Boolean)
Sets audio configuration, whether to play audio of video file and whether to play external (spatial) audio file
Declaration
public virtual void SetAudioConfig(bool internalAudio, bool externalAudio)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | internalAudio | set to true to enable video audio track |
| System.Boolean | externalAudio | set to true to enable external (spatial) audio track |
Remarks
Note
Enabling both internal and external audio causes both tracks to play simultaneously
Note
Enabling the external audio track without an external audio file being present in the project has no effect
SetEyes(Boolean, Boolean, String)
Stereoscopic settings
Declaration
public void SetEyes(bool InputIsStereo, bool OutputIsStereo, string Projection = "EQUIRECT")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | InputIsStereo | Is the video stereoscopic |
| System.Boolean | OutputIsStereo | Display in stereoscopic |
| System.String | Projection | projection keyword (e.g. EQUIRECT or FLAT) |
Remarks
Warning
This will be automatically set with Play(String, Boolean, Boolean, OnEnd). Use SetStereoscopicRendering(Boolean) to switch enable/disable the stereoscopic rendering
SetLoop(Boolean)
Declaration
protected abstract void SetLoop(bool loop)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | loop |
SetMute(Boolean)
Declaration
protected virtual void SetMute(bool mute)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | mute |
SetSeek(Single)
Declaration
protected abstract void SetSeek(float seek)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | seek |
SetSeekMs(Int64)
Declaration
protected virtual void SetSeekMs(long seek)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | seek |
SetStereoscopicRendering(Boolean)
Stereoscopic video rendering
Declaration
public void SetStereoscopicRendering(bool Stereoscopic)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | Stereoscopic | Render stereoscopic |
Remarks
Note
You can use this to disable the stereo effect if you want to display an interface
Examples
public void SwitchToMono()
{
App.Player.SetStereoscopicRendering(false);
}
SetTextureFlip(Boolean)
Declaration
protected void SetTextureFlip(bool requiresFlip)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | requiresFlip |
SetVolume(Single)
Declaration
protected virtual void SetVolume(float vol)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | vol |
Stop()
Stop the video
Declaration
public virtual void Stop()
Examples
public void StopVideo()
{
App.Player.Stop();
}