MythTV
master
programs
mythbackend
services
music.h
Go to the documentation of this file.
1
// Program Name: music.h
3
// Created : July 20, 2017
4
//
5
// Copyright (c) 2017 Paul Harrison <pharrison@mythtv.org>
6
//
7
// Licensed under the GPL v2 or later, see LICENSE for details
8
//
10
11
#ifndef MUSIC_H
12
#define MUSIC_H
13
14
#include "libmythbase/mythconfig.h"
15
#if CONFIG_QTSCRIPT
16
#include <QScriptEngine>
17
#endif
18
#include "
libmythservicecontracts/services/musicServices.h
"
19
20
class
Music
:
public
MusicServices
21
{
22
Q_OBJECT
23
24
public
:
25
26
Q_INVOKABLE
explicit
Music
( QObject *
/*parent*/
=
nullptr
) {}
27
28
public
:
29
30
/* Music Metadata Methods */
31
32
DTC::MusicMetadataInfoList
*
GetTrackList
(
int
StartIndex,
33
int
Count )
override
;
// MusicServices
34
35
DTC::MusicMetadataInfo
*
GetTrack
(
int
Id )
override
;
// MusicServices
36
37
38
};
39
40
// --------------------------------------------------------------------------
41
// The following class wrapper is due to a limitation in Qt Script Engine. It
42
// requires all methods that return pointers to user classes that are derived from
43
// QObject actually return QObject* (not the user class *). If the user class pointer
44
// is returned, the script engine treats it as a QVariant and doesn't create a
45
// javascript prototype wrapper for it.
46
//
47
// This class allows us to keep the rich return types in the main API class while
48
// offering the script engine a class it can work with.
49
//
50
// Only API Classes that return custom classes needs to implement these wrappers.
51
//
52
// We should continue to look for a cleaning solution to this problem.
53
// --------------------------------------------------------------------------
54
55
#if CONFIG_QTSCRIPT
56
class
ScriptableMusic :
public
QObject
57
{
58
Q_OBJECT
59
60
private
:
61
62
Music
m_obj;
63
QScriptEngine *m_pEngine;
64
65
public
:
66
67
Q_INVOKABLE
explicit
ScriptableMusic( QScriptEngine *pEngine, QObject *parent =
nullptr
) : QObject( parent )
68
{
69
m_pEngine = pEngine;
70
}
71
72
public
slots:
73
74
QObject* GetTrackList(
int
StartIndex,
75
int
Count )
76
{
77
SCRIPT_CATCH_EXCEPTION
(
nullptr
,
78
return
m_obj.
GetTrackList
(StartIndex, Count );
79
)
80
}
81
82
QObject* GetTrack(
int
Id )
83
{
84
SCRIPT_CATCH_EXCEPTION
(
nullptr
,
85
return
m_obj.
GetTrack
( Id );
86
)
87
}
88
};
89
90
// NOLINTNEXTLINE(modernize-use-auto)
91
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
( ScriptableMusic, QObject*);
92
#endif
93
94
#endif
Music::Music
Q_INVOKABLE Music(QObject *=nullptr)
Definition:
music.h:26
musicServices.h
Music
Definition:
music.h:20
Music::GetTrackList
DTC::MusicMetadataInfoList * GetTrackList(int StartIndex, int Count) override
Definition:
music.cpp:27
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
#define Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(T, _Arg1)
Definition:
service.h:113
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition:
service.h:85
DTC::MusicMetadataInfo
Definition:
musicMetadataInfo.h:25
DTC::MusicMetadataInfoList
Definition:
musicMetadataInfoList.h:24
Music::GetTrack
DTC::MusicMetadataInfo * GetTrack(int Id) override
Definition:
music.cpp:93
MusicServices
Definition:
musicServices.h:39
Generated on Tue Apr 16 2024 03:18:44 for MythTV by
1.8.17