コード例 #1
0
def play_some_commercials(max_commercials_per_break):
	try:
		comm_source = get_random_commercial()
		comm_player = OMXPlayer(comm_source, args=['--no-osd', '--blank'], dbus_name="omxplayer.player1")
		comm_player.set_video_pos(40,10,660,470);
		comm_player.set_aspect_mode('fill');
		comm_player.hide_video()
		comm_player.pause()
		#comm_player.set_volume(-1)
		comm_i = max_commercials_per_break
		while(comm_i>=0):
			comm_source = get_random_commercial()
			print('Playing commercial #' + str(comm_i), comm_source)
			contents = urllib2.urlopen("http://127.0.0.1/?current_comm=" + urllib.quote_plus(comm_source)).read()
			comm_player.load(comm_source)
			comm_player.pause()
			sleep(0.1)
			if comm_i==4:
				comm_player.show_video()
				
			comm_player.play()
			err_pos = 4
			while (1):
				try:
					comm_position = math.floor(comm_player.position())
				except:
					break
			comm_i = comm_i - 1
			sleep(1)
	except:
		print("Error playing commercial from function")
コード例 #2
0
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
up = 12
down = 11
enter = 7

#All Gpio's as input and pull up
GPIO.setup(up, GPIO.IN, pull_up_down=GPIO.PUD_UP
           )  # Set button "up" as input and Activate pull up resistor
GPIO.setup(down, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(enter, GPIO.IN, pull_up_down=GPIO.PUD_UP)

#Funny, the player quits after one run (while becomes False), but finishes without error. No loop = dbus error
player = OMXPlayer(default, args=['-o', 'local', '--loop'])
player.set_video_pos(
    200, 200, 627,
    440)  #video files are ?854 × 480px.? Divide with two + x1 and y1

while player.is_playing():
    #TODO: create a way for videos to be in a mill. Look over c# prg.

    #player = OMXPlayer(default, args=['-o', 'local'], )
    #player.set_video_pos(200, 200, 627, 440)

    if GPIO.input(up) == 0:
        player.load(vida)
        player.set_video_pos(200, 200, 627, 440)
        print("button1 pushed")
        player.play()
        #sleep(5)
コード例 #3
0
#All Gpio's as input and pull up
GPIO.setup(up, GPIO.IN, pull_up_down=GPIO.PUD_UP
           )  # Set button "up" as input and Activate pull up resistor
GPIO.setup(down, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(enter, GPIO.IN, pull_up_down=GPIO.PUD_UP)

#All players are playing at the same time!?! HOW TO FIX?
playerA = OMXPlayer('/home/pi/Desktop/video/ai.mp4',
                    args=['-o', 'local', '--loop'])
playerB = OMXPlayer('/home/pi/Desktop/video/Culture4Fun.mp4',
                    args=['-o', 'local', '--loop'])
playerC = OMXPlayer('/home/pi/Desktop/video/MT.mp4',
                    args=['-o', 'local', '--loop'])

playerA.play()
playerA.set_video_pos(200, 200, 627, 440)

while True:
    if GPIO.input(up) == 0:  #set in interrupt
        if playerA.is_playing() == True:
            playerB.set_video_pos(200, 200, 627, 440)
            playerB.play()
        elif playerB.is_playing == True:
            playerC.set_video_pos(200, 200, 627, 440)
            playerC.play()
        else:
            playerA.set_video_pos(200, 200, 627, 440)
            playerA.play()

    if GPIO.input(down) == 0:  # set in interrupt
        if playerC.is_playing() == True:
コード例 #4
0
def play_video(source, commercials, max_commercials_per_break):
	if source==None:
		return
	#os.system("killall -9 omxplayer");
	try:
		global next_video_to_play
		global last_video_played
		
		err_pos = -1.0
		
		if next_video_to_play=='':
			print("Last video played: " + last_video_played)
			urlcontents = urllib2.urlopen("http://127.0.0.1/?getshowname=" + urllib.quote_plus(source)).read()
			print("Response: ")
			print(urlcontents)
			acontents = urlcontents.split("|")
			#if last_video_played == contents and contents!="News":
			if acontents[1]!="0" and acontents[0]!="News":
				print("Just played this show, skipping")
				return
			last_video_played = acontents[0]
			print("Last video played: " + last_video_played)
		
		next_video_to_play=''
		
		err_pos = 0.0

		comm_source = get_random_commercial()
		err_pos = 0.1
		comm_player = OMXPlayer(comm_source, args=['--no-osd', '--blank'], dbus_name="omxplayer.player1")
		err_pos = 0.12
		comm_player.set_video_pos(40,10,660,470);
		comm_player.set_aspect_mode('fill');
		err_pos = 0.13
		comm_player.hide_video()
		err_pos = 0.14
		comm_player.pause()
		err_pos = 0.15
		#comm_player.set_volume(1)
		err_pos = 0.2
		
		print('Main video file:' + source)
		err_pos = 0.21
		contents = urllib2.urlopen("http://127.0.0.1/?current_video=" + urllib.quote_plus(source)).read()
		err_pos = 0.23
		player = OMXPlayer(source, args=['--no-osd', '--blank'], dbus_name="omxplayer.player0")
		err_pos = 0.3
		print('Boosting Volume by ' + str(get_volume(source)) + 'db')
		err_pos = 0.31
		player.set_video_pos(40,10,660,470);
		player.set_aspect_mode('fill');
		err_pos = 0.32
		#player.set_volume(get_volume(source))
		err_pos = 0.33
		sleep(1)
		err_pos = 1.0
		player.pause()
		err_pos = 1.1
		strSubtitles = player.list_subtitles()
		if(strSubtitles):
			player.hide_subtitles()
		err_pos = 1.2
		player.play()
		err_pos = 1.3
		lt = 0
		while (1):
			err_pos = 2.0
			try:
				position = player.position()
			except:
				break

			if check_video()==True:
				#check if an outside source wants to play a new video
				print('outside source video return')
				err_pos = 8.0
				player.hide_video()
				player.quit()
				comm_player.hide_video()
				comm_player.quit()
				sleep(0.5)
				return
			
			if len(commercials) > 0:
				#found a commercial break, play some commercials
				if math.floor(position)==commercials[0]:
					commercials.pop(0)
					player.hide_video()
					player.pause()
					sleep(0.5)
					comm_i = max_commercials_per_break
					err_pos = 3.0
					while(comm_i>=0):
						if check_video()==True or next_video_to_play!='':
							#check if an outside source wants to play a new video
							print('outside source video return')
							err_pos = 6.0
							player.hide_video()
							player.quit()
							comm_player.hide_video()
							comm_player.quit()
							sleep(0.5)
							return
					
						comm_source = get_random_commercial()
						print('Playing commercial #' + str(comm_i), comm_source)
						contents = urllib2.urlopen("http://127.0.0.1/?current_comm=" + urllib.quote_plus(comm_source)).read()
						comm_player.load(comm_source)
						comm_player.pause()
						sleep(0.1)
						if comm_i==4:
							comm_player.show_video()
							
						comm_player.play()
						err_pos = 4.0
						while (1):
							try:
								comm_position = math.floor(comm_player.position())
							except:
								break
						comm_i = comm_i - 1
						sleep(1)
					
					err_pos = 5.0
					player.show_video()
					player.play()

		err_pos = 7.0
		player.hide_video()
		sleep(0.5)
	except Exception as e:
		if(err_pos!=7.0):
			contents = urllib2.urlopen("http://127.0.0.1/?error=MAIN_" + str(err_pos) + "_" + urllib.quote_plus(str(e))).read()
		print("error main " + str(e))

	try:
		comm_player.quit()
	except Exception as ex:
		#contents = urllib2.urlopen("http://127.0.0.1/?error=COMMERCIAL_" + str(err_pos) + "_" + urllib.quote_plus(str(ex))).read()
		print("error comm quit " + str(ex))
	try:
		player.quit()
	except Exception as exx:
		#contents = urllib2.urlopen("http://127.0.0.1/?error=PLAYER_" + str(err_pos) + "_" + urllib.quote_plus(str(exx))).read()
		print("error player quit " + str(exx))
	
	return
コード例 #5
0
ファイル: Main.py プロジェクト: LarsRaschke/IdeenExpo
class View(QtGui.QMainWindow, gui.Ui_Form):
    
    # Signals
    game = pyqtSignal()

    def __init__(self):
        super(self.__class__, self).__init__()

        self.setupUi(self)

        self.time1.setValue(1)
        self.time2.setValue(1)
        self.time1.setMaximum(1)
        self.time2.setMaximum(1)

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.run)
        self.timer.start(1)  # Bei Autostart wirklich 1 ms da kein System im Hintergrund ist

        self.logo.setPixmap(QtGui.QPixmap("/home/pi/Public/bilder/logoS.png"))
        self.logoR.setPixmap(QtGui.QPixmap("/home/pi/Public/bilder/logo.png"))
        self.hintergrund.setPixmap(QtGui.QPixmap("/home/pi/Public/bilder/bg.png"))
        
        
    # Slot
    @pyqtSlot()
    def run(self):
        global mode
        global videoStart
        global explainTextStep
        global startGame
        if mode is 0:  # Savemode
            """
            Hier werden alle Werte zurück gesetzt
            """
            videoStart = True
            setInterrupt(13)
            explainTextStep = 0
            startGame = False
            self.startBildschirm.setVisible(True)
            mode = 1
        elif mode is 1:  # Startbildschirm
            pass
        elif mode is 2:  # Übergang Erklärphase
            removeInterrupt(13)
            setInterrupt(11)            
            self.startBildschirm.setVisible(False)
            self.sensorTexte.setVisible(True)
            mode = 3
        elif mode is 3:  # Erklärphase
            """
            Text anzeigen durch "explainTextStep"
            """
            if explainTextStep is 5:
                if not startGame:
                    startGame = True
                    setInterrupt(13)
                    removeInterrupt(11)
                    self.text.setText("Start Game")
            # Texte Anzeigen lassen
            else:
                self.text.setText(str(explainTextStep))
            pass
        elif mode is 4:  # Übergang Spielphase
            removeInterrupt(11)
            removeInterrupt(13)
            self.sensorTexte.setVisible(False)
            self.startBildschirm.setVisible(False)
            mode = 5
        elif mode is 5:  # Spielphase
            if videoStart:
                self.player = OMXPlayer('/home/pi/Public/Videos/teil1Neu.mp4')        
                self.time1.setMaximum(int(self.player.duration()))
                self.time2.setMaximum(int(self.player.duration()))
                self.player.set_video_pos(260, 300, 1690, 1080)
                videoStart = False
            if self.player.is_playing():                
                restTime = int(self.player.duration())-int(self.player.position())
                self.time1.setValue(restTime)
                self.time2.setValue(restTime)
                pass
                # Spielläuft
            else:
                # Spielfertig
                self.player.quit()
                mode = 0
        else:
            pass
コード例 #6
0
ファイル: omx01.py プロジェクト: sarodp/my-pygame-snippets
from time import sleep

xfile1 = '/home/pi/mp4/boxes.avi'
xfile2 = '/home/pi/mp4/c.mp4'
xfile3 = '/home/pi/mp4/cat.mov'

# This will start an `omxplayer` process, this might
# fail the first time you run it, currently in the
# process of fixing this though.
#player1 = OMXPlayer(xfile1)
player2 = OMXPlayer(xfile2)
#player3 = OMXPlayer(xfile3)

# The player will initially be paused
player1.set_video_pos(0, 50, 500, 300)
player2.set_video_pos(0, 300, 500, 600)
player3.set_video_pos(0, 600, 500, 900)

#player1.play()
sleep(2)
#player1.pause()

player2.play()
sleep(2)
#player2.pause()

#player3.play()
sleep(2)
#player3.pause()

# Kill the `omxplayer` process gracefully.