def onControl(self, control):
        if control == self.close_button:        self.stop()
        elif control == self.flip_button:       self.camera.flip_video()
        elif control == self.mirror_button:     self.camera.mirror_video()
        elif control == self.addon_settings_button:   __addon__.openSettings()
        elif control == self.camera_settings_button:   self.open_camera_settings()
        
        elif self.pan_tilt:
            if control == self.home_button:     home_location = self.camera.ptz_home_location(2)
            elif control == self.preset_button: self.toggle_preset()
            else:
                if control == self.up_button:     self.camera.ptz_move_up()
                elif control == self.down_button:   self.camera.ptz_move_down()
                elif control == self.left_button:   self.camera.ptz_move_left()
                elif control == self.right_button:  self.camera.ptz_move_right()
                elif control == self.top_left_button:       self.camera.ptz_move_top_left()
                elif control == self.top_right_button:      self.camera.ptz_move_top_right()
                elif control == self.bottom_left_button:    self.camera.ptz_move_bottom_left()
                elif control == self.bottom_right_button:   self.camera.ptz_move_bottom_right()

                monitor.waitForAbort(self.sensitivity)         #Move Button Sensitivity
                self.camera.ptz_stop_run()
                
        elif self.zoom:
            if control == self.zoom_in_button:     self.camera.ptz_zoom_in()
            elif control == self.zoom_out_button:   self.camera.ptz_zoom_out()

            self.monitor.waitForAbort(self.sensitivity)  #Move Button Sensitivity
            self.camera.ptz_zoom_stop()
Esempio n. 2
0
def play(camera_number, show_controls=None):
    """
    Function to call to play the IP Camera feed.  Determines if controls are shown or not.
    """

    camera = Camera(camera_number)

    if camera.Connected(monitor):

        if show_controls == None:
            show_controls = False  # Generic IP Cameras default without Controls
            if camera._type != GENERIC_IPCAM:  # Foscam Cameras default with Controls
                show_controls = True

        if show_controls:
            player = CameraControlsWindow(camera, monitor)
            player.start()

        else:
            url = camera.getStreamUrl(0)
            name = settings.getCameraName(camera.number)
            utils.log(
                2, 'Camera %s ::  Name: %s;  Url: %s' %
                (camera.number, name, url))

            listitem = xbmcgui.ListItem()
            listitem.setInfo(type='Video', infoLabels={'Title': name})
            listitem.setArt({'thumb': utils.get_icon(camera.number)})

            utils.log(
                1, 'Camera %s :: *** Playing Fullscreen ***   URL: %s' %
                (camera.number, url))
            player = xbmc.Player()
            player.play(url, listitem)

            if monitor.resume_previous_file():
                while not player.isPlaying() and not monitor.stopped(
                ) and not monitor.abortRequested():
                    monitor.waitForAbort(.5)
                while player.isPlaying(
                ) and not monitor.stopped() and not monitor.abortRequested():
                    monitor.waitForAbort(.5)
                monitor.maybe_resume_previous()
    else:

        utils.log(
            3,
            'Camera %s :: Camera is not configured correctly' % camera.number)
        utils.notify('Camera %s not configured correctly' % camera.number)
def play(camera_number, show_controls = None):
    """
    Function to call to play the IP Camera feed.  Determines if controls are shown or not.
    """

    camera = Camera(camera_number)

    if camera.Connected(monitor):

        if show_controls == None:
            show_controls = False   # Generic IP Cameras default without Controls
            if camera._type != GENERIC_IPCAM:    # Foscam Cameras default with Controls
                show_controls = True

        if show_controls:
            player = CameraControlsWindow(camera, monitor)
            player.start()
                
        else:
            url = camera.getStreamUrl(0)
            name = settings.getCameraName(camera.number)
            utils.log(2, 'Camera %s ::  Name: %s;  Url: %s' %(camera.number, name, url))
            
            listitem = xbmcgui.ListItem()
            listitem.setInfo(type = 'Video', infoLabels = {'Title': name})
            listitem.setArt({'thumb': utils.get_icon(camera.number)})

            utils.log(1, 'Camera %s :: *** Playing Fullscreen ***   URL: %s' %(camera.number, url))
            player = xbmc.Player()
            player.play(url, listitem)

            if monitor.resume_previous_file():
                while not player.isPlaying() and not monitor.stopped() and not monitor.abortRequested():
                      monitor.waitForAbort(.5)
                while player.isPlaying() and not monitor.stopped() and not monitor.abortRequested():
                      monitor.waitForAbort(.5)
                monitor.maybe_resume_previous()
    else:
        
        utils.log(3, 'Camera %s :: Camera is not configured correctly' %camera.number)
        utils.notify('Camera %s not configured correctly' %camera.number)
Esempio n. 4
0
    def onControl(self, control):
        if control == self.close_button: self.stop()
        elif control == self.flip_button: self.camera.flip_video()
        elif control == self.mirror_button: self.camera.mirror_video()
        elif control == self.addon_settings_button: __addon__.openSettings()
        elif control == self.camera_settings_button:
            self.open_camera_settings()

        elif self.pan_tilt:
            if control == self.home_button:
                home_location = self.camera.ptz_home_location(2)
            elif control == self.preset_button:
                self.toggle_preset()
            else:
                if control == self.up_button: self.camera.ptz_move_up()
                elif control == self.down_button: self.camera.ptz_move_down()
                elif control == self.left_button: self.camera.ptz_move_left()
                elif control == self.right_button: self.camera.ptz_move_right()
                elif control == self.top_left_button:
                    self.camera.ptz_move_top_left()
                elif control == self.top_right_button:
                    self.camera.ptz_move_top_right()
                elif control == self.bottom_left_button:
                    self.camera.ptz_move_bottom_left()
                elif control == self.bottom_right_button:
                    self.camera.ptz_move_bottom_right()

                monitor.waitForAbort(
                    self.sensitivity)  #Move Button Sensitivity
                self.camera.ptz_stop_run()

        elif self.zoom:
            if control == self.zoom_in_button: self.camera.ptz_zoom_in()
            elif control == self.zoom_out_button: self.camera.ptz_zoom_out()

            self.monitor.waitForAbort(
                self.sensitivity)  #Move Button Sensitivity
            self.camera.ptz_zoom_stop()
    def __init__(self):
        self.isRunning = True

        # Black Background
        background_fade_animation = [
            ("WindowOpen", ("effect=fade time=200")),
            ("WindowClose", ("effect=fade time=1500")),
        ]

        img = xbmcgui.ControlImage(0, 0, 1280, 720, filename=_black, aspectRatio=0)
        self.addControl(img)
        img.setAnimations(background_fade_animation)

        # Individual Camera positions setup
        urls = []
        files = []
        imgs = []
        imgs2 = []

        coords = [(0, 0, 640, 360), (640, 0, 640, 360), (0, 360, 640, 360), (640, 360, 640, 360)]

        effect = ["slide", "slide"]
        time = [1200, 1000]
        tween = ["back", "back"]
        easing = ["Out", "InOut"]
        animations = [
            [
                (
                    "WindowOpen",
                    ("effect={0} start=-640,-360 time={1} tween={2} easing={3}").format(
                        effect[0], time[0], tween[0], easing[0]
                    ),
                ),
                (
                    "WindowClose",
                    ("effect={0} end=-640,-360 time={1} tween={2} easing={3}").format(
                        effect[1], time[1], tween[1], easing[1]
                    ),
                ),
            ],
            [
                (
                    "WindowOpen",
                    ("effect={0} start=640,-360 time={1} tween={2} easing={3}").format(
                        effect[0], time[0], tween[0], easing[0]
                    ),
                ),
                (
                    "WindowClose",
                    ("effect={0} end=640,-360 time={1} tween={2} easing={3}").format(
                        effect[1], time[1], tween[1], easing[1]
                    ),
                ),
            ],
            [
                (
                    "WindowOpen",
                    ("effect={0} start=-640,360 time={1} tween={2} easing={3}").format(
                        effect[0], time[0], tween[0], easing[0]
                    ),
                ),
                (
                    "WindowClose",
                    ("effect={0} end=-640,360 time={1} tween={2} easing={3}").format(
                        effect[1], time[1], tween[1], easing[1]
                    ),
                ),
            ],
            [
                (
                    "WindowOpen",
                    ("effect={0} start=640,360 time={1} tween={2} easing={3}").format(
                        effect[0], time[0], tween[0], easing[0]
                    ),
                ),
                (
                    "WindowClose",
                    ("effect={0} end=640,360 time={1} tween={2} easing={3}").format(
                        effect[1], time[1], tween[1], easing[1]
                    ),
                ),
            ],
        ]

        # Acquire all Enabled & Connected cameras
        enabled_cameras = settings.getAllEnabledCameras(monitor)

        # Logic to ensure enabled cameras are placed in the correct position
        threads = []
        for window_position in "1234":
            position = int(window_position) - 1

            # Sets the initial image to the loader gif
            img1 = xbmcgui.ControlImage(*coords[position], filename=_loader, aspectRatio=0)
            self.addControl(
                img1
            )  # Bug was seen here previously, hence the 'try' and this will need to be investigated in future
            img1.setAnimations(animations[position])

            # Connected and Enabled Camera
            if len(enabled_cameras) > position:
                img2 = xbmcgui.ControlImage(*coords[position], filename="", aspectRatio=0)
                self.addControl(img2)
                img2.setAnimations(animations[position])

                control = [img1, img2]

                with Camera(enabled_cameras[position]) as camera:
                    stream_type = camera.getStreamType(1)
                    url = camera.getStreamUrl(1, stream_type)
                    prefix = "AllCamera"

                    if stream_type == 0:  # MJPEG
                        t = threading.Thread(target=self.getImagesMjpeg, args=(camera, url, control, prefix))

                    elif stream_type == 2:  # MJPEG Interlaced
                        t = threading.Thread(target=self.getImagesMjpegInterlace, args=(camera, url, control, prefix))

                    else:  # Snapshot
                        t = threading.Thread(target=self.getImagesSnapshot, args=(camera, url, control, prefix))

                    threads.append(t)
                    t.start()

            # No Camera so set the place holder image
            else:
                img1.setImage(_holder, useCache=False)

        if len(threads) > 0:
            self.doModal()

            # while not monitor.abortRequested() and self.isRunning:
            #    monitor.waitForAbort(1)

            monitor.maybe_resume_previous()
            monitor.waitForAbort(1)
            utils.remove_leftover_images("AllCamera")

        else:
            utils.log(2, "Unable to start All Camera Player")
            utils.notify("Player did not start.  Check camera settings.")
 def onAction(self, action):
     if action in (ACTION_PREVIOUS_MENU, ACTION_STOP, ACTION_NAV_BACK, ACTION_BACKSPACE):
         self.isRunning = False
         monitor.waitForAbort(0.2)
         self.close()
Esempio n. 7
0
    def __init__(self):
        self.isRunning = True

        # Black Background
        background_fade_animation = [
                                    ('WindowOpen', ("effect=fade time=200")),
                                    ('WindowClose', ("effect=fade time=1500"))
                                    ]

        img = xbmcgui.ControlImage(0, 0, 1280, 720, filename = _black, aspectRatio = 0)
        self.addControl(img)
        img.setAnimations(background_fade_animation)

        # Individual Camera positions setup
        urls = []
        files = []
        imgs = []
        imgs2 = []
        
        coords = [  (0, 0, 640, 360),   
                    (640, 0, 640, 360),
                    (0, 360, 640, 360),
                    (640, 360, 640, 360) ]
#        coords = [  (0, 480, 426, 240),
#                    (0, 0, 850, 480), 
#                    (426, 480, 426, 240),
#                    (850, 480, 426, 240), 
#                    (850, 240, 426, 240),  
#                    (850, 0, 426, 240) ]
					

        effect = ['slide', 'slide']
        time = [1200, 1000]
        tween = ['back', 'back']
        easing = ['Out', 'InOut']
        animations = [
                        [ ('WindowOpen', ("effect={0} start=-640,-360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0])),
                          ('WindowClose', ("effect={0} end=-640,-360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
                        [ ('WindowOpen', ("effect={0} start=640,-360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
                          ('WindowClose', ("effect={0} end=640,-360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
                        [ ('WindowOpen', ("effect={0} start=-640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
                          ('WindowClose', ("effect={0} end=-640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
                        [ ('WindowOpen', ("effect={0} start=640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
                          ('WindowClose', ("effect={0} end=640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ]
                        ]
#        animations = [
#                        [ ('WindowOpen', ("effect={0} start=-640,-360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0])),
#                          ('WindowClose', ("effect={0} end=-640,-360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
#                        [ ('WindowOpen', ("effect={0} start=640,-360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
#                          ('WindowClose', ("effect={0} end=640,-360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
#                        [ ('WindowOpen', ("effect={0} start=-640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
#                          ('WindowClose', ("effect={0} end=-640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
#                        [ ('WindowOpen', ("effect={0} start=640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
#                          ('WindowClose', ("effect={0} end=640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
#                        [ ('WindowOpen', ("effect={0} start=640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
#                          ('WindowClose', ("effect={0} end=640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ],
#                        [ ('WindowOpen', ("effect={0} start=640,360 time={1} tween={2} easing={3}").format( effect[0], time[0], tween[0], easing[0] )),
#                          ('WindowClose', ("effect={0} end=640,360 time={1} tween={2} easing={3}").format( effect[1], time[1], tween[1], easing[1] )) ]
#                        ]
						
						
						
        # Acquire all Enabled & Connected cameras
        enabled_cameras = settings.getAllEnabledCameras(monitor)

        # Logic to ensure enabled cameras are placed in the correct position
        threads = []
        for window_position in '1234':
#        for window_position in '123456':
            position = int(window_position) - 1

            # Sets the initial image to the loader gif
            img1 = xbmcgui.ControlImage(*coords[position], filename = _loader, aspectRatio = 0) 
            self.addControl(img1)  #Bug was seen here previously, hence the 'try' and this will need to be investigated in future
            img1.setAnimations(animations[position])

            # Connected and Enabled Camera
            if len(enabled_cameras) > position:
                img2 = xbmcgui.ControlImage(*coords[position], filename = '', aspectRatio = 0)
                self.addControl(img2)
                img2.setAnimations(animations[position])

                control = [img1, img2]

                with Camera(enabled_cameras[position]) as camera:
                    stream_type = camera.getStreamType(1)
                    url = camera.getStreamUrl(1, stream_type)
                    prefix = 'AllCamera'

                    if stream_type == 0:    #MJPEG
                        t = threading.Thread(target = self.getImagesMjpeg, args = (camera, url, control, prefix))
                        
                    elif stream_type == 2:  #MJPEG Interlaced
                        t = threading.Thread(target = self.getImagesMjpegInterlace, args = (camera, url, control, prefix))
                        
                    else:                   #Snapshot
                        t = threading.Thread(target = self.getImagesSnapshot, args = (camera, url, control, prefix))

                    threads.append(t)
                    t.start()
                

            # No Camera so set the place holder image    
            else:
                img1.setImage(_holder, useCache = False)  
                    
        if len(threads) > 0:
            self.doModal()    

            #while not monitor.abortRequested() and self.isRunning:       
            #    monitor.waitForAbort(1)

            monitor.maybe_resume_previous()
            monitor.waitForAbort(1)
            utils.remove_leftover_images('AllCamera')
            
        else:
            utils.log(2, 'Unable to start All Camera Player')
            utils.notify('Player did not start.  Check camera settings.')
Esempio n. 8
0
 def onAction(self, action):        
     if action in (ACTION_PREVIOUS_MENU, ACTION_STOP, ACTION_NAV_BACK, ACTION_BACKSPACE):
         self.isRunning = False
         monitor.waitForAbort(.2)
         self.close()