[EPGRefresh] removed NumVideoDecoders depend for background refresh
[enigma2-plugins.git] / epgrefresh / src / RecordAdapter.py
1 from __future__ import print_function
2
3 from Components.SystemInfo import SystemInfo
4
5 # MessageBox
6 from Screens.MessageBox import MessageBox
7 from Tools import Notifications
8
9 # Config
10 from Components.config import config
11
12 from . import STARTNOTIFICATIONID, NOTIFICATIONDOMAIN
13
14 class RecordAdapter:
15         backgroundCapable = True
16         def __init__(self, session):
17                 self.backgroundRefreshAvailable = True
18                 self.__service = None
19                 self.navcore = session.nav
20
21         def prepare(self):
22                 if not self.backgroundRefreshAvailable:
23                         return False
24                 if config.plugins.epgrefresh.enablemessage.value:
25                         Notifications.AddPopup(_("EPG refresh started in background."), MessageBox.TYPE_INFO, 4, STARTNOTIFICATIONID, domain = NOTIFICATIONDOMAIN)
26
27                 return True
28
29         def play(self, service):
30                 print("[EPGRefresh.RecordAdapter.play]")
31                 if not self.backgroundRefreshAvailable: return False
32                 self.stopStreaming()
33                 self.__service = self.navcore.recordService(service)
34                 if self.__service is not None:
35                         self.__service.prepareStreaming()
36                         self.__service.start()
37                         return True
38                 return False
39
40         def stopStreaming(self):
41                 if self.__service is not None:
42                         self.navcore.stopRecordService(self.__service)
43                         self.__service = None
44
45         def stop(self):
46                 print("[EPGRefresh.RecordAdapter.stop]")
47                 self.stopStreaming()
48