Hello, Welcome to Micorosoft Q&A,
So my question is, is there a way I can force the MediaPlayerElement to use UTF8 encoding instead of autodetection?
Currently, there is not such api to force the MediaPlayerElement to use UTF8 encoding for TimedTextSource
, the better way is convert the string as Utf8, then pass it to TimedTextSource
For example
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".txt");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
IBuffer buffer = await FileIO.ReadBufferAsync(file);
using (var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(buffer))
{
string text = dataReader.ReadString(buffer.Length);
var newbuffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);
using (var memstream = newbuffer.AsStream())
{
TimedTextSource source = TimedTextSource.CreateFromStream(memstream.AsRandomAccessStream());
}
}
}
Or do you see any other how to make first file working without bad characters?
Sure, you could filter the specific and replace it with you want one.
var temp = text.Replace('„', '"').Replace('“', '"');
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.