Skip to content

Commit

Permalink
Creating enum for MediaState and allowing OBSVideoSettings to be conf…
Browse files Browse the repository at this point in the history
…igured
  • Loading branch information
DrEsteban committed May 15, 2024
1 parent 98afbf2 commit c48737d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
36 changes: 32 additions & 4 deletions obs-websocket-dotnet/Types/MediaInputStatus.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace OBSWebsocketDotNet.Types
Expand All @@ -12,19 +13,34 @@ public class MediaInputStatus
/// State of the media input
/// </summary>
[JsonProperty(PropertyName = "mediaState")]
public string State { get; set; }
internal string StateString { get; set; }

/// <summary>
/// State of the media input
/// </summary>
public MediaState? State
{
get
{
if (!Enum.TryParse(StateString, out MediaState state))
{
return null;
}
return state;
}
}

/// <summary>
/// Total duration of the playing media in milliseconds. `null` if not playing
/// </summary>
[JsonProperty(PropertyName = "mediaDuration")]
public int? Duration { get; set; }
public long? Duration { get; set; }

/// <summary>
/// Position of the cursor in milliseconds. `null` if not playing
/// </summary>
[JsonProperty(PropertyName = "mediaCursor")]
public int Cursor { get; set; }
public long? Cursor { get; set; }

/// <summary>
/// Instantiate from JObject
Expand All @@ -40,4 +56,16 @@ public MediaInputStatus(JObject body)
/// </summary>
public MediaInputStatus() { }
}

public enum MediaState
{
OBS_MEDIA_STATE_NONE,
OBS_MEDIA_STATE_PLAYING,
OBS_MEDIA_STATE_OPENING,
OBS_MEDIA_STATE_BUFFERING,
OBS_MEDIA_STATE_PAUSED,
OBS_MEDIA_STATE_STOPPED,
OBS_MEDIA_STATE_ENDED,
OBS_MEDIA_STATE_ERROR
}
}
12 changes: 6 additions & 6 deletions obs-websocket-dotnet/Types/OBSVideoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ public class ObsVideoSettings
/// Numerator of the fractional FPS value
/// </summary>
[JsonProperty(PropertyName = "fpsNumerator")]
public double FpsNumerator { internal set; get; }
public double FpsNumerator { set; get; }

/// <summary>
/// Denominator of the fractional FPS value
/// </summary>
[JsonProperty(PropertyName = "fpsDenominator")]
public double FpsDenominator { internal set; get; }
public double FpsDenominator { set; get; }

/// <summary>
/// Base (canvas) width
/// </summary>
[JsonProperty(PropertyName = "baseWidth")]
public int BaseWidth { internal set; get; }
public int BaseWidth { set; get; }

/// <summary>
/// Base (canvas) height
/// </summary>
[JsonProperty(PropertyName = "baseHeight")]
public int BaseHeight { internal set; get; }
public int BaseHeight { set; get; }

/// <summary>
/// Width of the output resolution in pixels
/// </summary>
[JsonProperty(PropertyName = "outputWidth")]
public int OutputWidth { internal set; get; }
public int OutputWidth { set; get; }

/// <summary>
/// Height of the output resolution in pixels
/// </summary>
[JsonProperty(PropertyName = "outputHeight")]
public int OutputHeight { internal set; get; }
public int OutputHeight { set; get; }
}
}

0 comments on commit c48737d

Please sign in to comment.