Skip to content

Commit

Permalink
open separate audio file menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakseis committed Apr 4, 2024
1 parent a774faf commit 9546ea8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions Player/Player.rc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ BEGIN
MENUITEM "Upend", ID_ORIENTATION_UPEND
END
MENUITEM SEPARATOR
MENUITEM "Open Audio File...", ID_OPEN_AUDIO_FILE
MENUITEM "Open Subtitles File...", ID_OPENSUBTITLESFILE
POPUP "Open Subtitles"
BEGIN
Expand Down
31 changes: 29 additions & 2 deletions Player/PlayerDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ BEGIN_MESSAGE_MAP(CPlayerDoc, CDocument)
&CPlayerDoc::OnConvertVideosIntoCompatibleFormat)
ON_UPDATE_COMMAND_UI(ID_CONVERT_VIDEOS_INTO_COMPATIBLE_FORMAT,
&CPlayerDoc::OnUpdateConvertVideosIntoCompatibleFormat)
ON_COMMAND(ID_OPEN_AUDIO_FILE, &CPlayerDoc::OnOpenAudioFile)
ON_UPDATE_COMMAND_UI(ID_OPEN_AUDIO_FILE, &CPlayerDoc::OnUpdateOpenAudioFile)
END_MESSAGE_MAP()


Expand Down Expand Up @@ -726,7 +728,8 @@ BOOL CPlayerDoc::OnSaveDocument(LPCTSTR lpszPathName)

bool CPlayerDoc::openDocument(LPCTSTR lpszPathName, bool openSeparateFile /*= false*/)
{
reset();
if (!openSeparateFile)
reset();

CString currentDirectory;
if (auto fileName = PathFindFileName(lpszPathName))
Expand Down Expand Up @@ -782,6 +785,7 @@ bool CPlayerDoc::openDocument(LPCTSTR lpszPathName, bool openSeparateFile /*= fa
{
return false;
}
reset();
mappedAudioFile = dlg.GetPathName();
static_cast<CPlayerApp*>(AfxGetApp())->SetMappedAudioFile(lpszPathName, dlg.GetPathName());
}
Expand Down Expand Up @@ -1605,7 +1609,7 @@ void CPlayerDoc::OnConvertVideosIntoCompatibleFormat()

void CPlayerDoc::OnUpdateConvertVideosIntoCompatibleFormat(CCmdUI* pCmdUI)
{
if (GetPathName().IsEmpty())
if (GetPathName().IsEmpty() || !m_url.empty())
{
pCmdUI->Enable(false);
return;
Expand Down Expand Up @@ -1643,3 +1647,26 @@ void CPlayerDoc::OnUpdateConvertVideosIntoCompatibleFormat(CCmdUI* pCmdUI)
pCmdUI->Enable(false);
}
}

void CPlayerDoc::OnOpenAudioFile()
{
openDocument(GetPathName(), true);
}

void CPlayerDoc::OnUpdateOpenAudioFile(CCmdUI* pCmdUI)
{
if (GetPathName().IsEmpty() || !m_url.empty())
{
pCmdUI->Enable(false);
return;
}

const auto extension = PathFindExtension(GetPathName());
if (!_tcsicmp(extension, _T(".lst")) || !_tcsicmp(extension, _T(".url")))
{
pCmdUI->Enable(false);
return;
}

pCmdUI->Enable(true);
}
2 changes: 2 additions & 0 deletions Player/PlayerDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@ class CPlayerDoc : public CDocument, public FrameDecoderListener
afx_msg void OnUpdateFixEncoding(CCmdUI* pCmdUI);
afx_msg void OnConvertVideosIntoCompatibleFormat();
afx_msg void OnUpdateConvertVideosIntoCompatibleFormat(CCmdUI* pCmdUI);
afx_msg void OnOpenAudioFile();
afx_msg void OnUpdateOpenAudioFile(CCmdUI* pCmdUI);
};
3 changes: 2 additions & 1 deletion Player/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@
#define ID_ORIENTATION_RORATE_270 32798
#define ID_FIX_ENCODING 32799
#define ID_CONVERT_VIDEOS_INTO_COMPATIBLE_FORMAT 32800
#define ID_OPEN_AUDIO_FILE 32801

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 321
#define _APS_NEXT_COMMAND_VALUE 32801
#define _APS_NEXT_COMMAND_VALUE 32802
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 310
#endif
Expand Down

0 comments on commit 9546ea8

Please sign in to comment.