Hi all,
What is the proper way to get notified of the current service change without using a timer and pooling the information from the session.nav.getcurrentService() ?
Posted 24 July 2017 - 14:33
I don´t know how to do that in python, a simple shell script does the job too
#!/bin/sh # service_changed servicerefold="" while sleep 1; do servicerefnew=`/usr/bin/wget -O - -q http://127.0.0.1/web/getcurrent | /bin/grep -B 1 "\(<\|</\)e2servicename" | /bin/sed 's/<[^>]*>//g' | /bin/sed 's/^[ \t]*//' | /bin/sed '2d'` if [ "$servicerefnew" != "$servicerefold" ]; then # echo "service changed" /usr/bin/wget -q -O /dev/null "http://127.0.0.1/web/message?text=service%20changed%20!!&type=1&timeout=1" fi servicerefold="$servicerefnew" done &
Posted 24 July 2017 - 14:56
This is so not done...
use the serviceEventTracker and e.g. use the iPlayableService.evStart from there and then get the current service from Navigation.
In InfoBarGenerics there are enough examples...
Edited by littlesat, 24 July 2017 - 14:56.
WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W
Posted 24 July 2017 - 18:49
@mervica thank you for the answer, but pooling the state with python timer would be faster i think especially from a pluging context.
Thank you @littlsat, the serviceEventTracker used in the infobar dose not effectively help me it needs a screen and i want to watch for service change in the background.
i am using a timer to look for channel change every 1 second.
But i have not figured out how to get the service ID (sSID)..
def update_service_info(self): service = session.nav.getCurrentService() info = service and service.info() data = info and info.getInfoObject(iServiceInformation.sTransponderData) sref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()) name = sref.getServiceName() print sref.toString() cur_orbpos = data.get("orbital_position", INVALID_POSITION) cur_freq = data.get("frequency", 0) service_id = self.getinfo(iServiceInformation.sSID) print cur_orbpos,cur_freq,name, service_id
Posted 24 July 2017 - 19:43
service = session.nav.getCurrentService() info = service and service.info() data = info and info.getInfoObject(iServiceInformation.sTransponderData) name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName() service_id = self.session.nav.getCurrentlyPlayingServiceReference().toString().split(':')[3] # geting service id from service reference string sat_pos = str(data.get("orbital_position", INVALID_POSITION)) frequency = str(data.get("frequency", 0) / 1000) print name,sat_pos,frequency, service_id
This is how i get the information now how i can avoid pooling this information continuously and update it only on service change ?
Posted 25 July 2017 - 07:56
class Someclass : event_callbacks =[] self.session.nav.event.append(Someclass.service_event) # callback shoud be static method Someclass.event_callbacks.append(self.update_service_info) @staticmethod def service_event(evt): if (evt == iPlayableService.evStart): print "channel changed....!", evt for func in Someclass.event_callbacks: print func func()
This is how to get notified when some navigation events occur.
Thank you @littlsat for the eventtracker hint.
Plugins-Software managementStarted by coxa, 4 Jul 2024 plugins |
|
|||
installation mutiboxSE (enigma2) sat>IP clientStarted by knoepfle, 26 Dec 2022 satipclient, plugins, multiboxse |
|
|||
Blindscan plugin dumb questionStarted by RamboHack, 11 Mar 2021 blindscan, edision, edit and 2 more... |
|
|||
Plugin - Ability to retrieve NIB tuner configuration settings?Started by LoveMyDish, 4 Nov 2019 plugins, tuner |
|
|||
plugin/Python - I'm looking for a way to run a Youtube video from a certain position (not from the beginning)Started by s3n0, 14 Feb 2019 Python, plugin, youtube-dl |
|
0 members, 4 guests, 0 anonymous users