How can a script write to screen during video/picture playback?
#1
Sad 
Can anyone shed light on how to get a script to write to the screen while a video(dvd/xvid etc.) or pictures are being played back? Its straight forward doing it at any other time but for some reason doesn't work in the scenarios specified. Doesn't seem to matter which media player is used. Not sure if this is a bug or a recent design limitation as it worked over a year ago. I know this because all of the callerID scripts that worked fine no longer do during vid/pic playback.

Huh
cheers,

crazyivan
Reply
#2
Might get better response in the dev python board.
Reply
#3
Which render do you use (check XBMC video settings in the GUI)? and please post a debug log on pastebin.com (see the manual)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#4
Gamester17 Wrote:Which render do you use (check XBMC video settings in the GUI)? and please post a debug log on pastebin.com (see the manual)

I tried all of the renderer's and got the same results with all of them. With debugging enabled nothing untoward showed up in the log. The script log has no errors either. Here's the snippet around when the CID came in during xvid playback. As you can see nothing extra around 17:03:34 when the CID was attempted to be displayed:

Quote:17:03:20 M: 17838080 NOTICE: Display resolution AUTO : 1080i 16:9 (0)
17:03:20 M: 16826368 DEBUG: CGUIInfoManager::SetCurrentMovie, got movie info!
17:03:20 M: 16826368 DEBUG: Title = Eight Below
17:03:20 M: 17379328 DEBUG: Activating window ID: 12005
17:03:20 M: 17379328 DEBUG: Checking if window ID 12005 is locked.
17:03:20 M: 19722240 DEBUG: Setting resolution 0
17:03:20 M: 11284480 DEBUG: We set resolution 0
17:03:20 M: 11051008 DEBUG: Created YV12 texture 0
17:03:20 M: 11051008 INFO: Loading skin file: VideoFullscreen.xml
17:03:20 M: 11051008 INFO: Loading skin file: VideoOSD.xml
17:03:20 M: 10457088 INFO: Loading skin file: VideoOSDSettings.xml
17:03:20 M: 9744384 INFO: Loading skin file: VideoOSDSettings.xml
17:03:20 M: 9662464 DEBUG: CGUIFontTTF::Load Scaled size of font Q:\Media\Fonts\Arial.ttf (28): width = 76, height = 39
17:03:20 M: 9428992 DEBUG: msg: *** [vo] Allocating (slices) mp_image_t, 560x240x12bpp YUV planar, 201600 bytes
17:03:20 M: 9404416 DEBUG: msg: XXX initial v_pts=0.000 a_pos=5040 (0.504)
17:03:20 M: 9199616 DEBUG: msg: *** [vo] Allocating (slices) mp_image_t, 560x240x12bpp YUV planar, 201600 bytes
17:03:20 M: 8970240 DEBUG: msg: *** [vo] Allocating (slices) mp_image_t, 560x240x12bpp YUV planar, 201600 bytes
17:03:34 M: 8417280 INFO: (425) 555-1212
YAC Test Call
17:03:34 M: 8417280 INFO:
17:03:41 M: 8392704 DEBUG: CApplication::OnKey: 276 pressed, action is 85
17:03:46 M: 8392704 INFO: Screen shot saved as F:\Apps\XBMC\screenshot002.bmp
17:03:48 M: 8392704 DEBUG: CApplication::OnKey: 257 pressed, action is 9

Here's a snippet from earlier in the run when the CID was displayed correctly while in the main menu:

Quote:17:02:32 M: 29650944 NOTICE: Webserver: Started
17:02:32 M: 29003776 NOTICE: XBFileZilla: Started
17:02:46 M: 34287616 INFO: (425) 555-1212
YAC Test Call
17:02:46 M: 34287616 INFO:
17:02:53 M: 33640448 DEBUG: CApplication::OnKey: 276 pressed, action is 85
17:02:56 M: 33615872 INFO: Screen shot saved as F:\Apps\XBMC\screenshot001.bmp
17:03:05 M: 33550336 DEBUG: CApplication::OnKey: 271 pressed, action is 4
17:03:06 M: 34295808 DEBUG: CApplication::OnKey: 271 pressed, action is 4
17:03:08 M: 34295808 DEBUG: CApplication::OnKey: 256 pressed, action is

The freeware package YAC was used to trigger the script to write to the display. You just give it the xbox's IP under listeners then you can send it a test CID or text message from your PC. Here's the script I used, the server type would be YAC:

Code:
##################################################################
# Basic CallerID listener
# Coded by Rich-Hard ([email protected])
#
# Update to YAC2: now supports YAC, CallerID Sentry and software from Impulse Technology
#
# ** YAC Server Software:
#    http://www.sunflowerhead.com/software/yac/
#
# ** CID Sentry Server Software:
#    Windows: http://home.houston.rr.com/jeffkohn/callerid_sentry.htm
#    Macintosh: http://www.afterten.com/products/cidtracker/index.html
#    3Com Audry: http://www.timemocksme.com/acid/
#
# ** Impulse Technology Software (there are a number of options using this protocol):
#    http://www.imptec.com/index.html
#
# To add thumbnails for incoming calls, add [phonenumber].jpg
# into the CallerID subdirectory.  The filename must be the same number
# of digits as display in the callid, but should contain no extra
# characters such as hyphens or spaces.
##################################################################

import socket
import xbmc, xbmcgui, threading, thread
from time import *
from string import *

MYAREACODE = "403"        # SPECIFY YOUR AREA CODE
DELAY = 15            # SPECIFY DELAY BEFORE CLOSE IN SECONDS
DOLOG = 0            # SPECIFY WHETHER OR NOT TO WRITE TO LOG
DOIMAGE = 0            # SPECIFY WHETHER OR NOT TO DISPLAY PICTURE WITH DIALOG
SERVERTYPE = "YAC"        # SPECIFY EITHER "YAC", "CIDSENTRY" OR "IMPULSE"

YACPORT = 10629            # SPECIFY PORT FOR YAC
CIDSENTRYPORT = 4550        # SPECIFY PORT FOR CALLER ID SENTRY
CIDSENTRYIP = "192.168.0.49"    # SPECIFY IP ADDRESS FOR CALLER ID SENTRY SERVER
IMPULSEPORT = 42685        # SPECIFY PORT FOR IMPULSE

BIGENDIAN = 1            # 0 OR 1, IF ONE DOESN'T WORK, TRY THE OTHER

HOST = ''                # Symbolic name meaning the local host
class packet:
    def __init__(self, type, param1, param2 = "", param3 = ""):
        self.type = type
        self.param1 = param1
        self.param2 = param2
        self.param3 = param3

def decodepacket(the_string):
    if not(BIGENDIAN):
        type = ord(the_string[3])
        param1 = (ord(the_string[6]) * 256) + ord(the_string[7])
    else:
        type = ord(the_string[0])
        param1 = (ord(the_string[5]) * 256) + ord(the_string[4])

    param2 = the_string[8:72]
    param3 = the_string[72:]
    for i in range(-63, 0):
        if ord(param2[-i]) == 0: param2 = param2[:-i]
        if ord(param3[-i]) == 0: param3 = param3[:-i]
    return packet(type, param1, param2, param3)

def encodepacket(the_packet):
    r = " "
    if not(BIGENDIAN):
        r = r + chr(0)
    else:
        r = r + chr(the_packet.type)
    r = r[1:]
    r = r + chr(0)
    r = r + chr(0)

    if BIGENDIAN:
        r = r + chr(0)
    else:
        r = r + chr(the_packet.type)

    if not(BIGENDIAN):
        r = r + chr(the_packet.param1 - ((the_packet.param1 / 256) * 256))
    else:
        r = r + chr(the_packet.param1 - ((the_packet.param1 / 256) * 256))
        r = r + chr(the_packet.param1 / 256)
        r = r + chr(0)
        r = r + chr(0)

    r = r + the_packet.param2
    for i in range(len(r), 72):
        r = r + chr(0)
    r = r + the_packet.param3
    for i in range(len(r), 136):
        r = r + chr(0)
    return r

def formatnumber( n ):
    if len( n ) == 7:
        return "(" + MYAREACODE + ") " + n[:3] + "-" + n[3:]
    if len( n ) == 10:
        return "(" + n[:3] + ") " + n[3:6] + "-" + n[6:]
    if len( n ) == 11:
        return n[0] + " (" + n[1:4] + ") " + n[4:7] + "-" + n[7:]
    return n

def fileExists(f):
    try:
        file = open(f)
    except IOError:
        exists = 0
    else:
        exists = 1
    return exists

class caller(xbmcgui.WindowDialog):
    def __init__(self):

        w = self.getWidth()
        h = self.getHeight()
        self.bg = xbmcgui.ControlImage(w - 282, h - 138, 222, 103, "Q:\\scripts\\CallerID\\CallerID\\dialog.png")
        self.addControl(self.bg)
        self.callerid = xbmcgui.ControlLabel(w - 275, h - 95, 181, 64, data, 'font13', '0xff000000')
        self.addControl(self.callerid)
        if not DOIMAGE:
            self.title = xbmcgui.ControlLabel(w - 277, h - 133, 100, 10, 'Message', 'font13', '0xffffffff')
            self.addControl(self.title)
        else:
            self.frame = xbmcgui.ControlImage(w - 359, h - 138, 77, 103, "Q:\\scripts\\CallerID\\CallerID\\frame.png")
            self.addControl(self.frame)
            self.title = xbmcgui.ControlLabel(w - 354, h - 133, 100, 10, 'YAC Message', 'font13', '0xffffffff')
            self.addControl(self.title)
            filename = replace(number, '(', '')
            filename = replace(filename, ')', '')
            filename = replace(filename, ' ', '')
            filename = replace(filename, '-', '')
            filename = "Q:\\scripts\\CallerID\\CallerID\\" + filename + '.jpg'
            if not fileExists(filename): filename = "Q:\\scripts\\CallerID\\CallerID\\default.jpg"
            self.tn = xbmcgui.ControlImage(w - 359, h - 112, 77, 77, filename)
            self.addControl(self.tn)

        self.a = -1
        self.shown = 1

        subThread = threading.Thread(target=self.SubthreadProc, args=())
        subThread.start()

    def SubthreadProc(self):
        sleep(DELAY)
        if self.shown:
            self.close()

    def onAction(self, action):
        if self.a == action:
            self.shown = 0
            self.close()
        self.a = action


if SERVERTYPE == "CIDSENTRY":
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setblocking(1)
    s.bind((HOST, CIDSENTRYPORT))
    req = packet(1, CIDSENTRYPORT)
    rpack = encodepacket(req)
    s.sendto(rpack, (CIDSENTRYIP, CIDSENTRYPORT))
elif SERVERTYPE == "IMPULSE":
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setblocking(1)
    s.bind((HOST, IMPULSEPORT))
    req = packet(1, IMPULSEPORT)
else:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, YACPORT))

data = ""
name = ""
number = ""

while 1:
    if SERVERTYPE == "YAC":
        s.listen(1)
        conn, addr = s.accept()
        a = conn.recv(1024)
        alist = split(a[5:], "~")
        if len(alist) > 1:
            name = alist[0]
            number = alist[1]
            if (name == "Out of Area") and (number == "Out of Area") :            
                data = ""
            else:
                data = number + "\n" + name
        else:
            data = a
    elif SERVERTYPE == "CIDSENTRY":
        r = s.recv(1024)
        p = decodepacket(r)
        if p.type == 3:
            name = p.param2
            number = formatnumber(p.param3)
        data = number + "\n" + name
    elif SERVERTYPE == "IMPULSE":
        r=s.recv(1024)
        if r[:4] == "NAME":
            name = r[5:]
        elif r[:4] == "NMBR":
            number = formatnumber(replace(r[5:], "-", ""))
        if name != "" and number != "":
            data = number + "\n" + name

    if data != "":
        print(data)
        w = caller()
        w.doModal()
        del w
        if DOLOG == 1:
            log = open("Q:\\scripts\\CallerID\\call_log.txt", "a")
            logentry = asctime(localtime(time())) + ": " + replace(data, "\n", " (") + ")"
            log.write(logentry + "\n")
            log.close()
        if SERVERTYPE == "YAC": conn.close()
        data = ""
        name = ""
        number = ""

Is there an example usage of xbmcgui.WindowDialog that works during video/picture playback?
cheers,

crazyivan
Reply
#5
Hi,

I never had any problems showing a dialog with text using python when vids are playing.

Try using either a window xml dialog, or just a xbmc.notification builtin(look in the wiki)
Reply
#6
stanley87 Wrote:Hi,

I never had any problems showing a dialog with text using python when vids are playing.

Try using either a window xml dialog, or just a xbmc.notification builtin(look in the wiki)

Thanks stanley! That worked. For anyone that wants an example of an updated YAC callerID script that works with current builds this works for me:

Code:
##########################################################################################
#
# Working YAC CID script as of 02-09-2007.  Popup will be seen during video playback
# You might want to change "Out of Area" to whatever string your local Telco uses.
#
##########################################################################################

import socket
import xbmc
from string import *

YACPORT    = 10629
HOST = ''

data   = ''
Number = ''
Name   = ''

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, YACPORT))
print ("CID listening for YAC messages")
data = ""
Name = ""
Number = ""

while 1:
    s.listen(1)
    conn, addr = s.accept()
    a = conn.recv(1024)
    alist = split(a[5:], "~")
    if len(alist) > 1:
        Name = alist[0]
        Number = alist[1]
        # Don't bother displaying if no info is available
        if (Name == "Out of Area") and (Number == "Out of Area") :            
            data = ""
        else:
            data = Number + "\n" + Name
    else:
        data = a
        Name = "YAC Message"
        Number = a

    if data != "":
        # Use notification builtin which will work during video/picture playback
        cmd = 'XBMC.Notification(' + Name + ', ' + Number + ', 15000 )'
        xbmc.executebuiltin(cmd)
        cmd = ""
        print (data)
        data = ""
        Name = ""
        Number = ""
    conn.close()

The CID scripts available on XBMCscripts no longer work during video/picture playback. This does.
cheers,

crazyivan
Reply
#7
While this script is pretty old, it's simple and works. The newer YAC scripts run, but they only display the first few numbers and truncates the rest

e.g. (416) 4...

instead of (416) 444-4444

Just one issue with this. Once I start this script, it runs constantly in the background and prevents me from rebooting XBMC.

I don't have a clue how to write Python. Can someone show me what to add to make this script self-terminate when I hit the XBMC reboot button?

Thanks a lot.
Reply

Logout Mark Read Team Forum Stats Members Help
How can a script write to screen during video/picture playback?0