Ejemplo n.º 1
0
    def setUp(self):

        self.playerInfo = PlayerInfo()
        self.playerInfo.set_provider('yly', 'http://uri-logo.com')
        self.playerInfo.set_provider_name('yyy-second')

        self.playerInfo.set_lyric('http://uri-lrc.com')
        self.playerInfo.set_art('art')
        self.playerInfo.set_title('title')
        self.playerInfo.set_title_subtext1('sub text1')
        self.playerInfo.set_title_subtext2('sub text2')
        self.playerInfo.set_audio_item_type(PlayerInfoAudioItemEnum.FORMAT_LRC)
        self.playerInfo.set_media_length_in_ms(12321.232)

        favoriteButton = FavoriteButton()
        favoriteButton.set_enabled(False)
        self.playerInfo.add_control(favoriteButton)

        showPlayListButton = ShowPlayListButton()
        showPlayListButton.set_selected(True)
        self.playerInfo.set_controls(showPlayListButton)

        showFavoriteListButton = ShowFavoriteListButton()
        repeatButton = RepeatButton(RepeatButtonEnum.REPEAT_ONE)
        self.playerInfo.set_controls([showFavoriteListButton, repeatButton])
Ejemplo n.º 2
0
    def audioPlay(self):
        '''
        播放指令
        '''
        directives = []
        directive1 = Play(
            'http://audio.xmcdn.com/group27/M07/91/30/wKgJW1kVpTTysDS9ABG_opoNMoA008.m4a',
            PlayBehaviorEnum.REPLACE_ALL)
        playerInfo = PlayerInfo()
        playerInfo.set_title('Python')
        playerInfo.set_title_subtext1('python')
        playerInfo.set_art(
            'https://imagev2.xmcdn.com/group26/M03/94/DD/wKgJWFkVpOyzKhU_AABPh3rraa8772.jpg!op_type=5&upload_type=cover&device_type=ios&name=web_meduim&strip=0&quality=7'
        )

        playpause = PlayPauseButton()
        previous = PreviousButton()
        next = NextButton()
        showPlayList = ShowPlayListButton()
        showPlayList.set_enabled(False)
        controls = [playpause, previous, next, showPlayList]
        # controls = [playpause, previous]
        playerInfo.set_controls(controls)
        # playerInfo.add_control(NextButton())
        directive1.set_player_info(playerInfo)

        # directive2 = Play('http://audio.xmcdn.com/group27/M04/91/28/wKgJW1kVpMfRrzE5AAzyjIkEf9s698.m4a', PlayBehaviorEnum.ENQUEUE)
        # playerInfo = PlayerInfo()
        # playerInfo.set_title('子夜吴歌')
        # playerInfo.set_art(
        #     'https://imagev2.xmcdn.com/group26/M03/94/DD/wKgJWFkVpOyzKhU_AABPh3rraa8772.jpg!op_type=5&upload_type=cover&device_type=ios&name=web_meduim&strip=0&quality=7')
        # playpause = PlayPauseButton()
        # previous = PreviousButton()
        # previous.set_selected(True)
        # controls = [playpause, previous]
        # playerInfo.set_controls(controls)
        # playerInfo.add_control(NextButton())
        # directive2.set_player_info(playerInfo)
        # directive3 = Play('http://audio.xmcdn.com/group27/M04/91/28/wKgJW1kVpMfRrzE5AAzyjIkEf9s698.m4a', PlayBehaviorEnum.ENQUEUE)
        #
        # playerInfo = PlayerInfo()
        # playerInfo.set_title('子夜吴歌')
        # playerInfo.set_art(
        #     'https://imagev2.xmcdn.com/group26/M03/94/DD/wKgJWFkVpOyzKhU_AABPh3rraa8772.jpg!op_type=5&upload_type=cover&device_type=ios&name=web_meduim&strip=0&quality=7')
        # playpause = PlayPauseButton()
        # previous = PreviousButton()
        # previous.set_selected(True)
        # controls = [playpause, previous]
        # playerInfo.set_controls(controls)
        # playerInfo.add_control(NextButton())
        # directive3.set_player_info(playerInfo)
        directives.append(directive1)
        # directives.append(directive2)
        # directives.append(directive3)

        return {'directives': directives, 'outputSpeech': r'正在为你播放歌曲'}
Ejemplo n.º 3
0
class ShowFavoriteListButtonTest(unittest.TestCase):
    def setUp(self):
        self.showPlayListButton = ShowPlayListButton()
        self.showPlayListButton.set_enabled(False)
        self.showPlayListButton.set_selected(True)

    def testGetData(self):

        ret = {
            'type': 'BUTTON',
            'name': 'SHOW_PLAYLIST',
            'enabled': False,
            'selected': True
        }

        self.assertEqual(self.showPlayListButton.get_data(), ret)

    pass
Ejemplo n.º 4
0
    def testGetData(self):

        with open('../../json/render_video.json', encoding='utf-8') as f:
            content = f.read()
            self.data = json.loads(content)
        print(self.data)

        content = VideoPlayerInfoContent('title')
        content.set_media_length_in_milliseconds(10000)
        playPauseButton = PlayPauseButton()
        playlistButton = ShowPlayListButton()
        controls = [playPauseButton, playlistButton]

        self.renderVideoPlayerInfo.set_token('test_token')
        self.renderVideoPlayerInfo.set_content(content)
        self.renderVideoPlayerInfo.set_controls(controls)
        self.assertEqual(self.renderVideoPlayerInfo.get_data(), self.data)
    def testSS(self):
        content = VideoPlayerInfoContent('title')
        content.set_media_length_in_milliseconds(10000)
        playPauseButton = PlayPauseButton()
        playlistButton = ShowPlayListButton()
        controls = [playPauseButton, playlistButton]

        self.renderVideoPlayerInfo.set_token('test_token')
        self.renderVideoPlayerInfo.set_content(content)
        self.renderVideoPlayerInfo.set_controls(controls)
        directives = [self.renderVideoPlayerInfo]
        directives = list(
            map(
                lambda value: value.get_data(),
                list(
                    filter(lambda value: isinstance(value, BaseDirective),
                           directives))))
        print(directives)
Ejemplo n.º 6
0
def build_audio_play(index, audio):
    audio_url = audio['audio_path']
    directive = Play(audio_url)
    audio_content = AudioPlayerInfoContent()
    audio_content.set_title(audio['audio_name'])
    audio_content.set_title_subtext1(audio['audio_name'])
    audio_content.set_art(
        'http://imagev2.xmcdn.com/group10/M0B/85/50/wKgDZ1YgthSi0SHEAACtQo3lZK8096.jpg!op_type=5&upload_type=header&device_type=ios&name=web_x_large&strip=0&quality=7'
    )
    previous = PreviousButton()
    pause = PlayPauseButton()
    next = NextButton()
    play_list = ShowPlayListButton()
    play_info = AudioPlayerInfo(audio_content,
                                [previous, pause, next, play_list])
    directive.set_player_info(play_info)
    token = 'playlist:%s' % index
    directive.set_token(token)
    hint = Hint(['下一个/上一个'])
    return {
        'directives': [hint, directive],
        'outputSpeech': '即将播放:%s' % audio['audio_name']
    }
 def setUp(self):
     self.showPlayListButton = ShowPlayListButton()
     self.showPlayListButton.set_enabled(False)
     self.showPlayListButton.set_selected(True)