Open VTT and media file from plugin

Open
#263 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp
Domain
desktop

Research direction

Start by reading the plugin API usage around Main.OpenSubtitle, Main.SetSubtitle, Settings.RecentFiles, and VideoPlayer.Initialize. Trace how menu-based subtitle and media opening updates recent files, save targets, and restart state. Done means a plugin can open both file types through the intended API and the correct files persist, reopen, and remain associated with saving.

Written by the indexing model from the issue text.

Description

The first part of the problem that I'm running in to is opening the VTT (web based) in the app. Since Main.OpenSubtitle is hidden by the protection level I'm using Main.SetSubtitle. It opens just fine but when I go to save it seems to go to the latest entry in the Settings.RecentFiles. I've added my file(s) to the RecentFiles (and saving settings) but they don't display in the 'Reopen' menu and are lost when closing the app. Also, when the app is closed and restarted it reverts back to the last file opened from the menus.

Is there something I'm missing? Is there something in the plugin API that I should be using? I've also tried to change the protection level in SubtitleEdit source code to public but intellisense didn't pick up on it so it's unavailable. I probably have to compile and reference it but I'd like to do this the way it was intended rather than a source code change.

Second part is opening the media files (usually MP3 or WAV). I can't find any other way so I find the player control in Main and use VideoPlayer.Initialize to load the file. Seems to be the same issue (protection level).

Bottom line: how can I open files (subtitle and media) in a way that is consistent with opening the dialog box from the menu?

This code opens the MP3 file in the player but does not reopen after closing the app:
objVideoPlayer = (Nikse.SubtitleEdit.Controls.VideoPlayerContainer)objVP1s[0];
if (objVideoPlayer.VideoPlayer != null)
{
objVideoPlayer.VideoPlayer.Initialize(objVideoPlayer, strAudioFileName, EH1, EH2);
_parentForm.VideoAudioTrackNumber = 0;
}

This opens a VTT file but also does not reopen when the app is restarted nor will the correct file be written to when the save button is clicked:
Nikse.SubtitleEdit.Core.Common.Subtitle _subtitle = new Nikse.SubtitleEdit.Core.Common.Subtitle();
Encoding objEnc = Encoding.UTF8;
Nikse.SubtitleEdit.Core.Common.Subtitle objNEWST = new Core.Common.Subtitle();
_subtitle.LoadSubtitle(strTempVTTFileName, out objEnc, Encoding.UTF8);

Dominant language
C#
Stars
137
Forks
48
Avg merge
5m
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SubtitleEdit/plugins

All issues in SubtitleEdit/plugins

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.