summaryrefslogtreecommitdiff
path: root/playmenu.c
blob: 2943e94d1dcfae8e99fcc99acbc6276d7571873e (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
//////////////////////////////////////////////////////////////////////////////
///                                                                        ///
/// This file is part of the VDR mpv plugin and licensed under AGPLv3      ///
///                                                                        ///
/// See the README file for copyright information                          ///
///                                                                        ///
//////////////////////////////////////////////////////////////////////////////

#include "playmenu.h"
#include "config.h"
#include "mpv_service.h"
#include "filebrowser.h"

//////////////////////////////////////////////////////////////////////////////
// cOsdMenu
//////////////////////////////////////////////////////////////////////////////

cPlayMenu::cPlayMenu(const char *title, int c0, int c1, int c2, int c3, int c4)
:cOsdMenu(title, c0, c1, c2, c3, c4)
{
  SetHasHotkeys();

  Add(new cOsdItem(hk(tr("Browse")), osUser1));
  Add(new cOsdItem(hk(tr("Play optical disc")), osUser2));
  Add(new cOsdItem(""));
  Add(new cOsdItem(""));
  Add(new cOsdItem(hk(tr("Play audio CD")), osUser5));
  Add(new cOsdItem(hk(tr("Play video DVD")), osUser6));

  if (cMpvFilebrowser::CurrentDir() != "")
  {
    AddSubMenu(new cMpvFilebrowser(MpvPluginConfig->BrowserRoot.c_str()));
  }
}

cPlayMenu::~cPlayMenu()
{
}

/**
** Handle play plugin menu key event.
**
** @param key  key event
*/
eOSState cPlayMenu::ProcessKey(eKeys key)
{
  eOSState state;

  // call standard function
  state = cOsdMenu::ProcessKey(key);

  switch (state)
  {
    case osUser1:
      AddSubMenu(new cMpvFilebrowser(MpvPluginConfig->BrowserRoot.c_str()));
      return osContinue; // restart with OSD browser

    case osUser2:
      Skins.Message(mtStatus,
      tr("Function not working yet, use 3 or 4"));
      return osContinue;

    case osUser5: // play audio cdrom
      PlayFile("cdda://");
      return osEnd;

    case osUser6: // play dvd
      PlayFile("dvdnav://menu");
      return osEnd;

    default:
      break;
  }
  return state;
}

int cPlayMenu::PlayFile(const char *Filename)
{
  cPlugin *p;
  p = cPluginManager::GetPlugin("mpv");
  if (p)
  {
    Mpv_StartPlayService_v1_0_t r;
      r.Filename = (char *)Filename;

    return p->Service("Mpv-StartPlayService_v1_0", &r);
  }

  return false;
}