Skip to content

Commit

Permalink
v 0.3.0
Browse files Browse the repository at this point in the history
- Track selection (video/audio/sub)
- Custom Seek Values (in config.ini or via Settings Menu)
- Aspect Ratio Control (with custom ratio)
- Fix (disable Sleep Mode/Dimming on media playback)
- Small fiexs
  • Loading branch information
proconsule committed Oct 31, 2021
1 parent 54640f2 commit 40a4160
Show file tree
Hide file tree
Showing 23 changed files with 1,064 additions and 183 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := libs/imgui libs/imgui/misc/freetype source source/UI source/remotefs/Enigma2 source/remotefs/ftplib source/remotefs/HTTPDir
SOURCES := libs/imgui libs/imgui/misc/freetype source source/UI source/remotefs/Enigma2 source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
DATA := data
INCLUDES := libs/simpleini libs/imgui include source/remotefs/Enigma2 source/remotefs/ftplib source/remotefs/HTTPDir
INCLUDES := libs/simpleini libs/imgui include source/remotefs/Enigma2 source/localfs/usb source/remotefs/ftplib source/remotefs/HTTPDir
ROMFS := romfs

VERSION_MAJOR := 0
VERSION_MINOR := 2
VERSION_MICRO := 1
VERSION_MINOR := 3
VERSION_MICRO := 0

APP_TITLE := NXMP
APP_AUTHOR := proconsule
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Buttons Mapping
- R L ZR ZL (seek +/- during playback)
- \+ Exit NXMP
- R Stick Button Toggle Masterlock (during playback, only A button will work)
- Dpad Right (during playback show right menu)
- Dpad Left (during playback close right menu)


FAQ
Expand All @@ -58,6 +60,7 @@ FAQ
Thanks to
-----
- Cpasjuste for pPlay https://github.com/Cpasjuste/pplay some code was taken here (mpv part)
- DarkMatterCore for libusbhsfs https://github.com/DarkMatterCore/libusbhsfs (this gives NXMP USB support)
- bodyXY @ GBATemp forum for banner and icons
- docgold @ GBATemp forum for Enigma2 samples and support on decoders
- tataniko @ GBATemp forum for suggestions and bug hunting
Expand Down
21 changes: 21 additions & 0 deletions include/apppopups.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef NXMP_APPPOPUPS_H
#define NXMP_APPPOPUPS_H

#include "imgui.h"

namespace Popups {
inline void SetupPopup(const char *id) {
ImGui::OpenPopup(id);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(15, 15));
ImGui::SetNextWindowPos(ImVec2(640.0f, 360.0f), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
};

inline void ExitPopup(void) {
ImGui::EndPopup();
ImGui::PopStyleVar();
};

void SaveSettingsPopup(void);
}

#endif
14 changes: 0 additions & 14 deletions include/appwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,5 @@ namespace Windows {

}

namespace PlayerWindows {
inline void SetupWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 600.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 120.0f), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
};
inline void ExitWindow(void) {
ImGui::End();
ImGui::PopStyleVar();
};

void PlayerControls();

}

#endif
17 changes: 17 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@ class Config{
std::string getEnigma();
std::string getStartPath();

int getLongSeek(bool tmpvalue);
int getShortSeek(bool tmpvalue);

void setLongSeek(int seektime);
void setShortSeek(int seektime);

void saveSettings();

std::vector<std::string> topmenu;
CSimpleIniA *ini;

private:
int shortseek;
int longseek;

int tmpshortseek;
int tmplongseek;

std::string inifilePath;
};


Expand Down
56 changes: 56 additions & 0 deletions include/fileInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef NXMP_FILEINFO_H
#define NXMP_FILEINFO_H

#include <string>
#include <vector>

class fileInfo {

public:

class Track {
public:
int id;
std::string type;
std::string title = "Unknown";
std::string language = "N/A";
std::string codec;
int channels;
int bit_rate;
int sample_rate;
int width;
int height;
bool selected = false;
};

class Chapter{
public:
std::string title;
double time;
};

class Playback {
public:
int vid_id = -1;
int aud_id = -1;
int sub_id = -1;
int position = 0;
};


std::string title = "Unknown";
std::string path;
long duration = 0;
int bit_rate = 0;
std::vector<Track> videos;
std::vector<Track> audios;
std::vector<Track> subtitles;

std::vector<Chapter> chapters;

Playback playbackInfo;


};

#endif
24 changes: 24 additions & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#endif
#include <glad/glad.h>
#include "appwindows.h"
#include "apppopups.h"
#include "playerwindows.h"
#include "libmpv.h"
#include "config.h"
#include "remotefs.h"
Expand All @@ -33,10 +35,29 @@ enum MENU_STATES {
MENU_STATE_PLAYER
};

enum APP_POPUP_STATES {
POPUP_STATE_NONE,
POPUP_STATE_SAVE_SETTINGS
};

enum PLAYER_RIGHT_MENU_STATES {
PLAYER_RIGHT_MENU_PLAYER,
PLAYER_RIGHT_MENU_HOME,
PLAYER_RIGHT_MENU_TRACKS,
PLAYER_RIGHT_MENU_TRACKS_VIDEO,
PLAYER_RIGHT_MENU_TRACKS_AUDIO,
PLAYER_RIGHT_MENU_TRACKS_SUB,
PLAYER_RIGHT_MENU_CHAPTERS,
PLAYER_RIGHT_MENU_ARATIO,
PLAYER_RIGHT_MENU_CUSTOMARATIO
};


typedef struct {
MENU_STATES state = MENU_STATE_HOME;
MENU_STATES laststate = MENU_STATE_FILEBROWSER;
PLAYER_RIGHT_MENU_STATES rightmenustate = PLAYER_RIGHT_MENU_PLAYER;
APP_POPUP_STATES popupstate = POPUP_STATE_NONE;
int selected = 0;
std::string localpath = "/switch/nxmp";
std::vector<FS::FileEntry> localfileentries;
Expand All @@ -56,6 +77,9 @@ typedef struct {
bool first_item;
bool focus;

bool rightmenu_first_item;
bool rightmenu_focus;


} MenuItem;

Expand Down
29 changes: 25 additions & 4 deletions include/libmpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
#define NXMP_LIBMPVMPV_H

#include <string>
#include "fileInfo.h"

#include <mpv/client.h>
#include <mpv/render_gl.h>

struct decoderlist_struct{
std::string codecname;
std::string codecdesc;
};

class libMpv{
public:

Expand All @@ -19,27 +25,42 @@ class libMpv{

void Stop();

void seekSilent(double position);

void seekOSD(double position);
void seek(double position,bool osd);

bool Stopped();

bool Paused();

int64_t getPosition();

int64_t getVideoWidth();
int64_t getVideoHeight();

fileInfo *getFileInfo();

void setVid(int id, bool osd);
void setAid(int id, bool osd);
void setSid(int id, bool osd);

void setAspectRatio(double ratio,bool osd);

void getfileInfo();


mpv_handle *getHandle();

mpv_render_context *getContext();
std::vector<decoderlist_struct> getDecoderList();

std::string mpv_version;
std::string ffmpeg_version;

private:

mpv_handle *handle = nullptr;
mpv_render_context *context = nullptr;
std::vector<decoderlist_struct> decoderlist;
fileInfo * fileinfo = nullptr;

};

Expand Down
35 changes: 35 additions & 0 deletions include/playerwindows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef NXMP_PLAYERWINDOWS_H
#define NXMP_PLAYERWINDOWS_H

#include "imgui.h"


namespace playerWindows{
inline void SetupRightWindow(void) {
ImGui::SetNextWindowPos(ImVec2(1080.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(200.0f, 720.0f), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));

};

inline void ExitWindow(void) {
ImGui::End();
ImGui::PopStyleVar();
ImGui::PopStyleColor();
};



void RightHomeWindow(bool *focus, bool *first_item);
void RightTrackWindow(bool *focus, bool *first_item);
void RightChapterWindow(bool *focus, bool *first_item);
void RightTrackVideoWindow(bool *focus, bool *first_item);
void RightTrackAudioWindow(bool *focus, bool *first_item);
void RightTrackSubWindow(bool *focus, bool *first_item);
void RightHomeARatio(bool *focus, bool *first_item);
void RightHomeCustomARatio(bool *focus, bool *first_item);

}

#endif
3 changes: 2 additions & 1 deletion include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace Utility{
std::string toUpper(const std::string &str);
bool endsWith(const std::string &value, const std::string &ending, bool sensitive);
std::vector<std::string> getMediaExtensions();
std::string humanSize(uint64_t bytes);
std::string humanSize(size_t bytes);
std::string str_tolower(std::string s);
}

#endif
37 changes: 37 additions & 0 deletions source/UI/apppopups.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "apppopups.h"
#include "gui.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "utils.h"

namespace Popups{

void SaveSettingsPopup(void) {
Popups::SetupPopup("Save Settings");

if (ImGui::BeginPopupModal("Save Settings", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {

ImGui::Text("Save Settings?");

ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f);
if (ImGui::Button("Yes", button_size))
{
item.state = MENU_STATE_HOME;
item.popupstate = POPUP_STATE_NONE;
configini->saveSettings();

}
ImGui::SameLine();
if (ImGui::Button("No", button_size))
{

item.state = MENU_STATE_HOME;
item.popupstate = POPUP_STATE_NONE;
ImGui::CloseCurrentPopup();
}

}
Popups::ExitPopup();
}

}
Loading

0 comments on commit 40a4160

Please sign in to comment.