def test_operate_on_not_exists_playlist(self): change = """ [ { "type": "remove_playlist", "playlist_id": "10" } ] """ p = PlayList() p.load_data(StringIO(INPUT)) with self.assertRaises(PlayListException): p.apply_changes(StringIO(change)) change = """ [ { "type": "add_song_to_playlist", "playlist_id": "100", "song_ids" : ["2"] } ] """ p = PlayList() p.load_data(StringIO(INPUT)) with self.assertRaises(PlayListException): p.apply_changes(StringIO(change))
def test_input_valiate(self): p = PlayList() ## playlist's user_id is invalid input = """ { "users" : [{"id" : "1", "name" : "Albin Jaye"} ], "playlists" : [{"id" : "1", "user_id" : "2", "song_ids" : ["1"] } ], "songs": [{"id" : "1", "artist": "Camila Cabello", "title": "Never Be the Same"} ] } """ with self.assertRaises(PlayListException): p.load_data(StringIO(input)) # playlist's song_id is invalid input = """ { "users" : [{"id" : "1", "name" : "Albin Jaye"} ], "playlists" : [{"id" : "1", "user_id" : "1", "song_ids" : ["2"] } ], "songs": [{"id" : "1", "artist": "Camila Cabello", "title": "Never Be the Same"} ] } """ with self.assertRaises(PlayListException): p.load_data(StringIO(input))
def test_change_input(self): p = PlayList() p.load_data(StringIO(INPUT)) # below schema in change: # 1. option type is not valid # 2. miss filed 'song_ids' change = """ [ { "type": "invalid_option" } ] """ with self.assertRaises(PlayListException): p.apply_changes(StringIO(change)) change = """ [ { "type": "add_song_to_playlist", "playlist_id": "2" } ] """ with self.assertRaises(PlayListException): p.apply_changes(StringIO(change))
def __init__(self, video_dir, gapless=True): self.previous = None self.current = None self.next = None self.video_dir = video_dir self.track_list = os.listdir(self.video_dir) self.list = PlayList(caller=self, maxsize=len(self.track_list))
def init_ui(self): self.main_menu = MainMenu(self) self.setting_dialog = SettingDialog(self) self.title_widget = TitleWidget(self) self.btn_mainmenu = self.title_widget.btn_mainmenu self.btn_min = self.title_widget.btn_min self.btn_max = self.title_widget.btn_max self.btn_close = self.title_widget.btn_close self.controlbar = ControlBar() self.controlbar.setFixedHeight(48) self.btn_open = self.controlbar.btn_open self.btn_play = self.controlbar.btn_play self.btn_pause = self.controlbar.btn_pause self.btn_stop = self.controlbar.btn_stop self.btn_fullscreen = self.controlbar.btn_fullscreen self.btn_playlist = self.controlbar.btn_playlist self.lab_time = self.controlbar.lab_time self.seekslider = self.controlbar.seekslider self.volumeslider = self.controlbar.volumeslider self.video.setMinimumSize(650, 350) #self.playlist = PlayList(_('PlayList')) self.playlist = PlayList() self.playlist.setFixedSize(150, 850) # playlist is hidden by default #self.playlist.hide() title_layout = QtGui.QHBoxLayout() title_layout.addWidget(self.title_widget) center_layout = QtGui.QHBoxLayout() center_layout.addWidget(self.video) center_layout.setSpacing(0) center_layout.addWidget(self.playlist) bottom_layout = QtGui.QHBoxLayout() bottom_layout.addWidget(self.controlbar) main_layout = QtGui.QGridLayout(self) main_layout.addLayout(title_layout, 0, 0) main_layout.addLayout(center_layout, 1, 0) main_layout.setSpacing(0) main_layout.addLayout(bottom_layout, 2, 0, 1, 2) # Fill the window with all contents, no gap in border. main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout)
def createPlaylistDock(self): from playlist import PlayList self.next_id = 0 self.playlist = PlayList(self, None) self.playlistdock = QW.QDockWidget() self.playlistdock.setWindowTitle("Playlist") self.playlistdock.setFeatures(QW.QDockWidget.DockWidgetFloatable| QW.QDockWidget.DockWidgetMovable) self.playlistsplit = QW.QSplitter() self.playlistsplit.setOrientation(Q.Qt.Vertical) self.playlistsplit.addWidget(self.playlist) # tv = self.dockprops = Q.QTreeView() # self.playlistsplit.addWidget(tv) self.playlistdock.setWidget(self.playlistsplit)
def test_normal_case(self): p = PlayList() p.load_data(StringIO(INPUT)) p.apply_changes(StringIO(CHANGE)) output = StringIO() p.gen_output(output) obj = json.loads(output.getvalue()) self.assertEqual(len(obj['users']), 1) self.assertEqual(obj['users'][0]['id'], '1') self.assertEqual(len(obj['playlists']), 2) self.assertEqual(obj['playlists'][0]['id'], '2') self.assertEqual(obj['playlists'][0]['song_ids'], ['1', '2']) self.assertEqual(obj['playlists'][1]['id'], '3') self.assertEqual(obj['playlists'][1]['song_ids'], ['1', '2'])
def test_not_allow_duplicate_song_in_playlist(self): change = """ [ { "type": "add_song_to_playlist", "playlist_id": "1", "song_ids" : ["1"] } ] """ p = PlayList() p.load_data(StringIO(INPUT)) p.apply_changes(StringIO(change)) output = StringIO() p.gen_output(output) obj = json.loads(output.getvalue()) self.assertEqual(len(obj['playlists'][0]['song_ids']), 2)
def __init__(self, **kwargs): """ Initialize the screens and the screen manager """ self._store = JsonStore("zenplayer.json") self.playlist = PlayList(self._store) self.sm = ScreenManager() self.playing = PlayingScreen(self, name="main") self.sm.add_widget(self.playing) self.sm.current = "main" if platform not in ['ios', 'android']: self.kb_listener = ZenKeyboardListener(self) Sound.add_state_callback(self.playing.on_sound_state) Sound.add_state_callback(self._on_sound_state) super(Controller, self).__init__(**kwargs) if self._store.exists('state'): state = self._store.get("state") if "volume" in state.keys(): self.volume = state["volume"]
from playlist import PlayList my_playlist = PlayList() my_playlist.append("Country Roads") my_playlist.append("Heart on Ice") my_playlist.append("Rap God") my_playlist.append("Chicken in the CornBread") my_playlist.print_songs() my_playlist.prepend("Apple Bottom Jeans") my_playlist.print_songs() my_playlist.delete_from_head() my_playlist.print_songs() my_playlist.delete_from_tail() my_playlist.print_songs() print(my_playlist.find('Rap God')) print(my_playlist.find("Chicken in the CornBread")) my_playlist.delete("Heart on Ice") my_playlist.print_songs() my_playlist.reverse() my_playlist.print_songs() my_playlist.append("Country Roads") my_playlist.append("Heart on Ice") my_playlist.append("Rap God") my_playlist.append("Chicken in the CornBread") my_playlist.print_songs() my_playlist.reverse() my_playlist.print_songs()
# i=0 # while i <len(lista): # print(lista[i]) # i=i+1 # def mostrar(s="Hello", n=2): # for i in range (0, n): # print(s) # # mostrar('Michael', 4) from cancion import Cancion from playlist import PlayList l = PlayList() while True: print('1 Agregar Cancion') print('2 Mostrar Cnaciones') print('0 Salir') op = input() if op == '1': cancion = Cancion() cancion.artista = input("Artista") cancion.album = input("Album") cancion.titulo = input("Titulo") cancion.duracion = int(input("Duaracion")) l.agregar(cancion) elif op == '2':
def __init__(self, handle): activity.Activity.__init__(self, handle) self.player = None self._alert = None self._playlist_jobject = None self.set_title(_('Jukebox Activity')) self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_toolbar = activity_button.page toolbar_box.toolbar.insert(activity_button, 0) self.title_entry = activity_toolbar.title self._view_toolbar = ViewToolbar() self._view_toolbar.connect('go-fullscreen', self.__go_fullscreen_cb) self._view_toolbar.connect('toggle-playlist', self.__toggle_playlist_cb) view_toolbar_button = ToolbarButton(page=self._view_toolbar, icon_name='toolbar-view') self._view_toolbar.show() toolbar_box.toolbar.insert(view_toolbar_button, -1) view_toolbar_button.show() self._control_toolbar = Gtk.Toolbar() self._control_toolbar_button = ToolbarButton( page=self._control_toolbar, icon_name='media-playback-start') self._control_toolbar.show() toolbar_box.toolbar.insert(self._control_toolbar_button, -1) self._control_toolbar_button.hide() self.set_toolbar_box(toolbar_box) toolbar_box.show_all() self.connect('key_press_event', self.__key_press_event_cb) self.connect('playlist-finished', self.__playlist_finished_cb) # We want to be notified when the activity gets the focus or # loses it. When it is not active, we don't need to keep # reproducing the video self.connect('notify::active', self.__notify_active_cb) self._video_canvas = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self._playlist_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.playlist_widget = PlayList() self.playlist_widget.connect('play-index', self.__play_index_cb) self.playlist_widget.connect('missing-tracks', self.__missing_tracks_cb) self.playlist_widget.set_size_request( Gdk.Screen.width() * PLAYLIST_WIDTH_PROP, 0) self.playlist_widget.show() self._playlist_box.pack_start(self.playlist_widget, expand=True, fill=True, padding=0) self._playlist_toolbar = Gtk.Toolbar() move_up = ToolButton("go-up") move_up.set_tooltip(_("Move up")) move_up.connect("clicked", self._move_up_cb) self._playlist_toolbar.insert(move_up, 0) move_down = ToolButton("go-down") move_down.set_tooltip(_("Move down")) move_down.connect("clicked", self._move_down_cb) self._playlist_toolbar.insert(move_down, 1) self._playlist_box.pack_end(self._playlist_toolbar, False, False, 0) self._video_canvas.pack_start(self._playlist_box, False, False, 0) # Create the player just once logging.debug('Instantiating GstPlayer') self.player = GstPlayer() self.player.connect('eos', self.__player_eos_cb) self.player.connect('error', self.__player_error_cb) self.player.connect('play', self.__player_play_cb) self.control = Controls(self, toolbar_box.toolbar, self._control_toolbar) self._separator = Gtk.SeparatorToolItem() self._separator.props.draw = False self._separator.set_expand(True) self._separator.show() toolbar_box.toolbar.insert(self._separator, -1) self._stop = StopButton(self) toolbar_box.toolbar.insert(self._stop, -1) self._empty_widget = Gtk.Label(label="") self._empty_widget.show() self.videowidget = VideoWidget() self.set_canvas(self._video_canvas) self._init_view_area() self.show_all() # need hide the playlist by default self._playlist_box.hide() self._configure_cb() self.player.init_view_area(self.videowidget) self._volume_monitor = Gio.VolumeMonitor.get() self._volume_monitor.connect('mount-added', self.__mount_added_cb) self._volume_monitor.connect('mount-removed', self.__mount_removed_cb) if handle.object_id is None: # The activity was launched from scratch. We need to show # the Empty Widget self.playlist_widget.hide() emptypanel.show(self, 'activity-jukebox', _('No media'), _('Choose media files'), self.control.show_picker_cb) self.control.check_if_next_prev() Gdk.Screen.get_default().connect('size-changed', self._configure_cb)