Skip to content

Player (Open)

SuRGeoNix edited this page Nov 8, 2022 · 1 revision

Open / OpenAsync

Workflow

Preparing the Player. You select the purpose / usage of the Player with Config.Player.Usage (AVS/Audio/VideoLowLatency) you choose the Min/Max Buffer Duration with Config.Player.MinBufferDuration and Config.Demuxer.BufferDuration.

For more options available check Config.cs, FFmpeg Formats and FFmpeg Protocols

  1. You call Player.Open() or Player.OpenAsync() and provide a Url (string) or a Custom IO Stream (System.IO.Stream)
  2. Plugins will process your input and they will provide you their own Playlist Items
  3. If you set defaultPlaylistItem=false you will have to choose and open one available Playlist Items (Player.Playlist.Items) otherwise Plugins will choose for you
  4. If you set defaultVideo=false you will have to choose and open one from the streams available (Player.Video.Streams or Playlist.Selected.ExternalVideoStream) otherwise the Plugins will choose for you (currently based on the max resolution of your connected monitors)
  5. if you set defaultAudio=false you will have to choose and open one from the streams available (Player.Audio.Streams or Playlist.Selected.ExternalAudioStream) otherwise the Plugins will choose for you (currently based on Config.Audio.Languages by priority and based on program that the selected video is to avoid extra bandwidth in case of network stream)
  6. If you set defaultSubtitles=false you will have to choose and open one from the streams available (Player.Subtitles.Streams or Playlist.Selected.ExternalSubtitlesStream) otherwise the Plugins might search local and/or online (Config.Subtitles.Search Local/Online) / choose for you (currently based on Config.Subtitles.Languages by priority and based on program that the selected video is to avoid extra bandwidth in case of network stream)
  7. Finally, you will get Event notifications from OpenXCompleted for each open that you have called

Example 1 - Basic (url)

  1. You call Player.OpenAsync(video_file_path) with all the defaults
  2. Plugins will provide a single Playlist Item with the provided video_file_path
  3. Player will Open the Playlist Item
  4. Player will Open the default AudioStream/VideoStream/SubtitlesStream (you can be notified from Player.decoder.OpenXStreamCompleted for each one that actually opened)
  5. You will be notified by the OpenCompleted event

Example 2 - Manual Selections

  1. You call Player.Open(youtube_url, false, false, false, false) -no defaults-
  2. You call Player.Open(Player.Playlist.Items[0], false, false, false) -no defaults- to open the first playlist item
  3. You call Player.Open(Player.Video.Streams[0], false, false) -no defaults- to open the first video stream
  4. You call Player.Open(Player.Audio.Streams[0], false, false) -no defaults- to open the first audio stream
  5. You call Player.Open(subtitles_url) to open manually a subtitles url
  6. Now that you have opened a playlist item and audio/video/subtitles streams you can start playing Player.Play()

A similar example could be with torrent streaming (BitSwarm) plugin while you open a Season torrent with multiple video files. It could choose for you (as it does by default the first from the sorted list) or you could have your own way to choose (so you open with defaultPlaylistItem=false)

Switch Inputs / Streams

Switching between inputs or streams does not require to Pause the Player. It can happened while IsPlaying. When switching has completed, it will resync the inputs / streams and you will be notified with the changes by the OpenXStreamCompleted events

If you switching video streams it is recommended to use the defaultAudio=true to allow it to follow the new VideoStream in case of network streams to avoid additional bandwidth (AudioStream might enables also another VideoStream and you get the bandwidth of 2 videos)

If you Open multiple streams during initial Open (e.g. for Audio/Video/Subtitles streams) at once, disable the resync to avoid multiple seeks and set it only at the last one which should be the video stream.

Open vs OpenAsync

Open will block when OpenAsync won't. Events will be fired in any case but when you call blocking Open you can get the open results (args) directly. Useful when you want to run a complex open workflow as above to do all the steps in a single thread. From the other hand, OpenAsync calls with defaults have the advantage of thread-safe and fast aborts embedded functionality.

OpenFromClipboard

OpenFromFileDialog

Clone this wiki locally