Files
pgsql-jellyfin/MediaBrowser.MediaEncoding/Subtitles/JsonWriter.cs
T
wjones af1152b001 Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
2026-02-20 16:26:53 -05:00

49 lines
1.5 KiB
C#

// <copyright file="JsonWriter.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace MediaBrowser.MediaEncoding.Subtitles
{
using System.IO;
using System.Text.Json;
using System.Threading;
using MediaBrowser.Model.MediaInfo;
/// <summary>
/// JSON subtitle writer.
/// </summary>
public class JsonWriter : ISubtitleWriter
{
/// <inheritdoc />
public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken)
{
using (var writer = new Utf8JsonWriter(stream))
{
var trackevents = info.TrackEvents;
writer.WriteStartObject();
writer.WriteStartArray("TrackEvents");
for (int i = 0; i < trackevents.Count; i++)
{
cancellationToken.ThrowIfCancellationRequested();
var current = trackevents[i];
writer.WriteStartObject();
writer.WriteString("Id", current.Id);
writer.WriteString("Text", current.Text);
writer.WriteNumber("StartPositionTicks", current.StartPositionTicks);
writer.WriteNumber("EndPositionTicks", current.EndPositionTicks);
writer.WriteEndObject();
}
writer.WriteEndArray();
writer.WriteEndObject();
writer.Flush();
}
}
}
}