From cd597993404271616530d7a3f0a525fdf5f06051 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Jun 2014 12:08:54 -0400 Subject: [PATCH] fix vtt with chrome --- MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs | 11 ++--------- MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs index 657aa17b38..ffb891b97d 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.IO; +using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -10,9 +11,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken) { - var writer = new StreamWriter(stream); - - try + using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { var index = 1; @@ -34,12 +33,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles index++; } } - catch - { - writer.Dispose(); - - throw; - } } } } diff --git a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs index a82f273f06..09f45aa61d 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -9,9 +10,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken) { - var writer = new StreamWriter(stream); - - try + using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { writer.WriteLine("WEBVTT"); writer.WriteLine(string.Empty); @@ -30,12 +29,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles writer.WriteLine(string.Empty); } } - catch - { - writer.Dispose(); - - throw; - } } } }