示例#1
0
	def onPlayingCommand(self, prefix, interest, transport, prefixId):
		
		interestName = Name(interest.getName())
		commandComponent = interest.getName().get(self.prefix.size())
		if commandComponent == Name.Component("stop"):
			pass
		if commandComponent == Name.Component("play"):
			pass
		else:
			songName = commandComponent.toEscapedString()
	    
		songList = []
		songList = songName.split('%2C')
	    
		for i in songList:
			fmusic = i + str("-music.mp3") 
			print "started getting music file", i
			
			g = GetFile(self._repoCommandPrefix, i, self._face, self.getOnset, i)
			
			g.oStream = open(fmusic,'wb')
			g.start()
			
			#self._getFiles.append(g)
			
		d = Data(interest.getName())
		d.setContent("start to play: " + songName + "\n")
		encodedData = d.wireEncode()
		transport.send(encodedData.toBuffer())	
示例#2
0
    def onPlayingCommand(self, prefix, interest, transport, prefixId):
	print "receive interest"
        interestName = Name(interest.getName())
        commandComponent = interest.getName().get(self.prefix.size())
        if commandComponent == Name.Component("stop"):
            pass
        if commandComponent == Name.Component("play"):
            pass
        else:
            songName = commandComponent.toEscapedString()
	    print songName
	    songList = []
	    songList = songName.split('%2C')
	    print "songlist and its len",songList,len(songList)
	    for i in songList:
		self.song = i
            	fmusic = i+str("-music.mp3") 
		self.ftxt = i + str("-os.txt")
		self.ffreq = i + str("-freq.txt")
		print "FMUSIC:",fmusic 
		  
	    	self.thread = threading.Thread(target = self.mp.play_music, args = (fmusic,songList,self.q,))
	    	self.thread.daemon = True
            	g = GetFile(self._repoCommandPrefix, i, self._face, self.getOnset)
		#g = GetFile(self._repoCommandPrefix, ftxt, self._face, self.lightFunction)
            	g.oStream = open(fmusic,'wb')
            	g.start()
	   
		
	
	d = Data(interest.getName())
	d.setContent("start to play: " + songName + "\n")
	encodedData = d.wireEncode()
	transport.send(encodedData.toBuffer())	
示例#3
0
    def getOnset(self):
	print "getonset"
	otxt = self.song+str("-o")
	print otxt
	g = GetFile(self._repoCommandPrefix, otxt, self._face, self.getFreq)
	g.oStream = open(self.song+str("-os.txt"),'wb')    
	g.start()
示例#4
0
	def getFreq(self, musicName):
		ftxt = musicName + str("-f")
		#get freq file, it will run play_music after finishing download
		print musicName, " get Freq called"
		g = GetFile(self._repoCommandPrefix, ftxt, self._face, self.mp.play_music, musicName, False)
		g.oStream = open(musicName + str("-freq.txt"),'wb')
		g.start()
示例#5
0
	def getOnset(self, musicName):
		otxt = musicName + str("-o")
		print otxt
		#get onset data file, it will then run getFreq after finishing download
		g = GetFile(self._repoCommandPrefix, otxt, self._face, self.getFreq, musicName)
		g.oStream = open(musicName + str("-os.txt"), 'wb')
		g.start()
示例#6
0
    def onPlayingCommand(self, prefix, interest, transport, prefixId):

        interestName = Name(interest.getName())
        commandComponent = interest.getName().get(self.prefix.size())
        if commandComponent == Name.Component("stop"):
            pass
        if commandComponent == Name.Component("play"):
            pass
        else:
            songName = commandComponent.toEscapedString()

        songList = []
        songList = songName.split('%2C')

        for i in songList:
            fmusic = i + str("-music.mp3")
            print "started getting music file", i

            g = GetFile(self._repoCommandPrefix, i, self._face, self.getOnset,
                        i)

            g.oStream = open(fmusic, 'wb')
            g.start()

            #self._getFiles.append(g)

        d = Data(interest.getName())
        d.setContent("start to play: " + songName + "\n")
        encodedData = d.wireEncode()
        transport.send(encodedData.toBuffer())
示例#7
0
 def getFreq(self, musicName):
     ftxt = musicName + str("-f")
     print musicName, " get Freq called"
     g = GetFile(self._repoCommandPrefix, ftxt, self._face,
                 self.mp.play_music, musicName, False)
     g.oStream = open(musicName + str("-freq.txt"), 'wb')
     g.start()
示例#8
0
 def getOnset(self, musicName):
     otxt = musicName + str("-o")
     print otxt
     g = GetFile(self._repoCommandPrefix, otxt, self._face, self.getFreq,
                 musicName)
     g.oStream = open(musicName + str("-os.txt"), 'wb')
     g.start()
示例#9
0
    def getFreq(self):
	print "getfreq"
	ftxt = self.song+str("-f")
	g = GetFile(self._repoCommandPrefix, ftxt, self._face, self.playFunction)
	g.oStream = open(self.song+str("-freq.txt"),'wb')    
	g.start()
示例#10
0
	def getFreq(self, musicName):
		ftxt = musicName + str("-f")
		print musicName, " get Freq called"
		g = GetFile(self._repoCommandPrefix, ftxt, self._face, self.mp.play_music, musicName, False)
		g.oStream = open(musicName + str("-freq.txt"),'wb')
		g.start()
示例#11
0
	def getOnset(self, musicName):
		otxt = musicName + str("-o")
		print otxt
		g = GetFile(self._repoCommandPrefix, otxt, self._face, self.getFreq, musicName)
		g.oStream = open(musicName + str("-os.txt"), 'wb')
		g.start()