private void Save() { var path = _vid.clip.originalPath.Replace(".mp4", "_.json"); if (File.Exists(path)) { if (!EditorUtility.DisplayDialog("File exists", "Overwrite existing file?", "Save", "Cancel")) { return; } } SrtParse.Save(_metasubs, _vid.clip.originalPath.Replace(".mp4", "_custom.srt")); SrtParse.SaveJson(_metasubs, path); _isDirty = false; }
private void LoadJSON() { if (_isDirty) { if (!EditorUtility.DisplayDialog("Unsaved changes", "Unsaved changed will be lost if you load, continue?", "Load", "Cancel")) { return; } } var path = _vid.clip.originalPath.Replace(".mp4", "_.json"); if (!File.Exists(path)) { Debug.Log("No existing JSON file found"); return; } _metasubs = SrtParse.LoadJson(path); _isDirty = false; }
void Awake() { _src = gameObject.GetComponent <AudioSource>(); _vid = gameObject.GetComponent <VideoPlayer>(); string srtPath = _vid.clip.originalPath.Replace("_.mp4", "_eng.srt"); var subs = SrtParse.Load(srtPath); SrtParse.Sanitize(subs); _metasubs = new List <SubMeta>(subs.Count); for (int i = 0; i < subs.Count; i++) { _metasubs.Add(new SubMeta() { Subtitle = subs[i] }); } _vid.seekCompleted += OnSeekCompleted; _vid.prepareCompleted += OnPrepared; _vid.Prepare(); }