blob: 82fe5cc56cd6aba3ac7efa44a0c3e1fd4ea63935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
//////////////////////////////////////////////////////////////////////////////
/// ///
/// This file is part of the VDR mpv plugin and licensed under AGPLv3 ///
/// ///
/// See the README file for copyright information ///
/// ///
//////////////////////////////////////////////////////////////////////////////
#ifndef __MPV_PLAYER_H
#define __MPV_PLAYER_H
#include <string>
#include <vector>
#include <vdr/player.h>
#include <mpv/client.h>
using std::string;
using std::vector;
class cMpvPlayer:public cPlayer
{
private:
void PlayerStart();
void SwitchOsdToMpv();
string PlayFilename; // file to play
bool PlayShuffle; // shuffle playlist
pthread_t ObserverThreadHandle; // player property observer thread
mpv_handle *hMpv; // handle to mpv
int OriginalFps; // fps before modeswitch
bool IsPlaylist(string File); // returns true if the given file is a playlist
void ChangeFrameRate(int TargetRate);
void HandlePropertyChange(mpv_event *event); // handle change mpv property
void HandleTracksChange(); // handle mpv track information
static void *ObserverThread(void *handle);
// Player status variables
int PlayerPaused; // player paused
int PlayerDiscNav; // discnav active
int PlayerNumChapters; // number of chapters
int PlayerChapter; // current chapter
int PlayerFps; // frames per second
int PlayerCurrent; // current postion in seconds
int PlayerTotal; // total length in seconds
string PlayerFilename; // filename currently playing
int PlayerSpeed; // player playback speed
vector<int> PlayerChapters; // chapter start times
vector<string> ChapterTitles; // chapter titles
string mediaTitle; // title from meta data
static volatile int running;
public:
cMpvPlayer(string Filename, bool Shuffle=false);
virtual ~cMpvPlayer();
void Activate(bool); // player attached/detached
virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId);
virtual void SetSubtitleTrack(eTrackType Type, const tTrackId *TrackId);
void OsdClose(); // clear or close current OSD
void Shutdown();
static volatile int PlayerIsRunning() { return running; }
// functions to send commands to mpv
void SendCommand(const char *cmd, ...);
void Seek(int Seconds); // seek n seconds
void SetTimePos(int Seconds);
void SetSpeed(int Speed);
void SetAudio(int Audio);
void SetSubtitle(int Subtitle);
void TogglePause();
void QuitPlayer();
void DiscNavUp();
void DiscNavDown();
void DiscNavLeft();
void DiscNavRight();
void DiscNavMenu();
void DiscNavSelect();
void DiscNavPrev();
void PreviousChapter();
void NextChapter();
void NextPlaylistItem();
void PreviousPlaylistItem();
void SetVolume(int Volume);
// functions to get different status information about the current playback
int IsPaused() { return PlayerPaused; }
int DiscNavActive() { return PlayerDiscNav; }
int NumChapters() { return PlayerNumChapters; }
int CurrentChapter() { return PlayerChapter + 1; } // return the current value +1 since mpv begins at 0
int CurrentPlayTime() { return PlayerCurrent; }
int TotalPlayTime() { return PlayerTotal; }
int CurrentFps() { return PlayerFps; }
string CurrentFile() { return PlayerFilename; }
int CurrentPlaybackSpeed() { return PlayerSpeed; }
int ChapterStartTime(unsigned int Chapter) { if (Chapter <= PlayerChapters.size()) return PlayerChapters[Chapter-1]; else return 0; }
string ChapterTitle(unsigned int Chapter) { if (Chapter <= ChapterTitles.size()) return ChapterTitles[Chapter-1]; else return ""; }
string MediaTitle() { return mediaTitle; }
};
#endif
|