Ticket #3025: mythmusic_resume_r12685.patch
File mythmusic_resume_r12685.patch, 13.2 KB (added by , 17 years ago) |
---|
-
mythmusic/mythmusic/playbackbox.cpp
116 116 else 117 117 setShuffleMode(SHUFFLE_OFF); 118 118 119 QString resumestring = gContext->GetSetting("ResumeMode", "playlist"); 120 if (resumestring.lower() == "playlist") 121 resumemode = RESUME_OFF; 122 else if (resumestring.lower() == "track") 123 resumemode = RESUME_TRACK; 124 else 125 resumemode = RESUME_EXACT; 126 119 127 QString repeatmode = gContext->GetSetting("RepeatMode", "all"); 120 128 if (repeatmode.lower() == "track") 121 129 setRepeatMode(REPEAT_TRACK); … … 232 240 delete cd_reader_thread; 233 241 } 234 242 243 all_playlists->getActive()->setBookmark(all_playlists->getActive()->getBookmarkSong(), 1000*currentTime); 244 235 245 if (playlist_tree) 236 246 delete playlist_tree; 237 247 … … 311 321 else if (action == "STOP") 312 322 { 313 323 stop(); 324 currentTime = 0; 314 325 } 315 326 else if (action == "THMBUP") 316 327 increaseRating(); … … 923 934 branches_to_current_node.append(0); // Root node 924 935 branches_to_current_node.append(1); // We're on a playlist (not "My Music") 925 936 branches_to_current_node.append(0); // Active play Queue 926 music_tree_list->moveToNodesFirstChild(branches_to_current_node); 937 if (resumemode > RESUME_OFF) 938 { 939 if (all_playlists->getActive()->checkTrack(all_playlists->getActive()->getBookmarkSong(), false)) 940 { 941 branches_to_current_node.append(all_playlists->getActive()->getBookmarkSong()); 942 music_tree_list->moveToNode(branches_to_current_node); 943 } 944 else 945 { 946 music_tree_list->moveToNodesFirstChild(branches_to_current_node); 947 } 948 } 949 else 950 { 951 if (all_playlists->getActive()->checkTrack(all_playlists->getActive()->getFirstTrackID(), false)) 952 { 953 branches_to_current_node.append(all_playlists->getActive()->getFirstTrackID()); 954 music_tree_list->moveToNode(branches_to_current_node); 955 } 956 else 957 { 958 music_tree_list->moveToNodesFirstChild(branches_to_current_node); 959 } 960 } 927 961 music_tree_list->refresh(); 928 962 if (show_whole_tree) 929 963 setContext(1); … … 937 971 938 972 play(); 939 973 974 if (resumemode == RESUME_EXACT) 975 seek(all_playlists->getActive()->getBookmarkSongOffset()/1000); 976 940 977 return; // Do not restart Timer 941 978 } 942 979 else … … 1246 1283 mdata->Title()); 1247 1284 } 1248 1285 1249 void PlaybackBoxMusic::pause(bool state)1286 void PlaybackBoxMusic::pause(bool) 1250 1287 { 1251 1288 if (output) 1252 1289 { … … 1324 1361 if (info_text) 1325 1362 info_text->SetText(""); 1326 1363 1364 all_playlists->getActive()->setBookmark(all_playlists->getActive()->getBookmarkSong(), 0); 1365 1327 1366 isplaying = false; 1328 1367 if (play_button) 1329 1368 play_button->setState(false); … … 1927 1966 if (output) 1928 1967 { 1929 1968 stop(); 1969 all_playlists->getActive()->setBookmark(node_int, 0); 1930 1970 play(); 1931 } 1971 } 1972 else 1973 { 1974 uint offset; 1975 if (node_int == all_playlists->getActive()->getBookmarkSong()) 1976 offset = all_playlists->getActive()->getBookmarkSongOffset(); 1977 else 1978 offset = 0; 1979 1980 all_playlists->getActive()->setBookmark(node_int, offset); 1981 } 1932 1982 } 1933 1983 else 1934 1984 { -
mythmusic/mythmusic/playlist.h
105 105 int currentTrackID = 0); 106 106 QString getSonglist(void) { return raw_songlist; } 107 107 108 void setBookmark(uint song, uint offset); 109 uint getBookmarkSong(void) { return resume_song; } 110 uint getBookmarkSongOffset(void) { return resume_offset; } 111 108 112 void moveTrackUpDown(bool flag, Track *the_track); 109 113 110 114 bool checkTrack(int a_track_id, bool cd_flag); … … 140 144 QString name; 141 145 QString raw_songlist; 142 146 QPtrList<Track> songs; 147 uint resume_song; 148 uint resume_offset; 143 149 AllMusic *all_available_music; 144 150 PlaylistsContainer *parent; 145 151 bool changed; -
mythmusic/mythmusic/globalsettings.cpp
312 312 gc->addSelection(QObject::tr("Random"), "Random"); 313 313 gc->addSelection(QObject::tr("Intelligent"), "Intelligent"); 314 314 gc->setHelpText(QObject::tr("Starting shuffle mode for the player. Can be " 315 "either normal, random, or intelligent (random).")); 315 "either normal, random, intelligent (random), or Album.")); 316 return gc; 317 }; 318 319 static HostComboBox *ResumeMode() 320 { 321 HostComboBox *gc = new HostComboBox("ResumeMode"); 322 gc->setLabel(QObject::tr("Resume mode")); 323 gc->addSelection(QObject::tr("Playlist"), "playlist"); 324 gc->addSelection(QObject::tr("Track"), "track"); 325 gc->addSelection(QObject::tr("Exact"), "exact"); 326 gc->setCurrent(0); 327 gc->setHelpText(QObject::tr("Resume playback at either the beginning of the " 328 "playlist, the beginning of the last track, an exact point within " 329 "the last track.")); 316 330 return gc; 317 331 }; 318 332 … … 533 547 VerticalConfigurationGroup* playersettings = new VerticalConfigurationGroup(false); 534 548 playersettings->setLabel(QObject::tr("Playback Settings")); 535 549 playersettings->addChild(PlayMode()); 550 playersettings->addChild(ResumeMode()); 536 551 playersettings->addChild(SetRatingWeight()); 537 552 playersettings->addChild(SetPlayCountWeight()); 538 553 playersettings->addChild(SetLastPlayWeight()); -
mythmusic/mythmusic/dbcheck.cpp
9 9 #include "mythtv/mythcontext.h" 10 10 #include "mythtv/mythdbcon.h" 11 11 12 const QString currentDatabaseVersion = "100 7";12 const QString currentDatabaseVersion = "1008"; 13 13 14 14 static bool UpdateDBVersionNumber(const QString &newnumber) 15 15 { … … 477 477 return false; 478 478 } 479 479 480 if (dbver == "1007") 481 { 482 const QString updates[] = { 483 "ALTER TABLE music_playlists ADD COLUMN resume_song INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER playlist_songs;", 484 "ALTER TABLE music_playlists ADD COLUMN resume_offset INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER resume_song;", 485 "" 486 }; 487 if (!performActualUpdate(updates, "1008", dbver)) 488 return false; 489 } 490 480 491 /* in 0.21 */ 481 492 //"DROP TABLE musicmetadata;", 482 493 //"DROP TABLE musicplaylist;", -
mythmusic/mythmusic/playlist.cpp
63 63 } 64 64 else 65 65 it = songs.next(); 66 } 66 } 67 68 if (resume_song == 0) 69 resume_song = getFirstTrackID(); 67 70 } 68 71 69 72 bool Playlist::checkTrack(int a_track_id, bool cd_flag) … … 183 186 } 184 187 else 185 188 it = songs.next(); 186 } 189 } 190 191 if (static_cast<int>(resume_song) == the_track) 192 resume_song = getFirstTrackID(); 193 187 194 changed = true; 188 195 } 189 196 … … 375 382 playlistid = 0; 376 383 name = QObject::tr("oops"); 377 384 raw_songlist = ""; 385 resume_song = 0; 386 resume_offset = 0; 378 387 songs.setAutoDelete(true); // mine! 379 388 all_available_music = all_music_ptr; 380 389 changed = false; … … 436 445 name = rhs.name; 437 446 raw_songlist = rhs.raw_songlist; 438 447 songs = rhs.songs; 448 resume_song = rhs.resume_song; 449 resume_offset = rhs.resume_offset; 439 450 return *this; 440 451 } 441 452 … … 473 484 474 485 if (name == "default_playlist_storage" || name == "backup_playlist_storage") 475 486 { 476 query.prepare("SELECT playlist_id, playlist_name, playlist_songs "487 query.prepare("SELECT playlist_id, playlist_name, playlist_songs, resume_song, resume_offset " 477 488 "FROM music_playlists " 478 489 "WHERE playlist_name = :NAME" 479 490 " AND hostname = :HOST;"); … … 482 493 { 483 494 // Technically this is never called as this function is only used to load 484 495 // the default/backup playlists. 485 query.prepare("SELECT playlist_id, playlist_name, playlist_songs "496 query.prepare("SELECT playlist_id, playlist_name, playlist_songs, resume_song, resume_offset " 486 497 "FROM music_playlists " 487 498 "WHERE playlist_name = :NAME" 488 499 " AND (hostname = '' OR hostname = :HOST);"); … … 497 508 playlistid = query.value(0).toInt(); 498 509 name = QString::fromUtf8(query.value(1).toString()); 499 510 raw_songlist = query.value(2).toString(); 511 resume_song = query.value(3).toInt(); 512 resume_offset = query.value(4).toInt(); 500 513 } 501 514 if (name == "default_playlist_storage") 502 515 name = "the user should never see this"; … … 517 530 void Playlist::loadPlaylistByID(int id, QString a_host) 518 531 { 519 532 MSqlQuery query(MSqlQuery::InitCon()); 520 query.prepare("SELECT playlist_id, playlist_name, playlist_songs "533 query.prepare("SELECT playlist_id, playlist_name, playlist_songs, resume_song, resume_offset " 521 534 "FROM music_playlists " 522 535 "WHERE playlist_id = :ID" 523 536 " AND (hostname = '' OR hostname = :HOST);"); … … 531 544 playlistid = query.value(0).toInt(); 532 545 name = QString::fromUtf8(query.value(1).toString()); 533 546 raw_songlist = query.value(2).toString(); 547 resume_song = query.value(3).toInt(); 548 resume_offset = query.value(4).toInt(); 534 549 } 535 550 536 551 if (name == "default_playlist_storage") … … 799 814 fillSonglistFromQuery(whereClause, removeDuplicates, insertOption, currentTrackID); 800 815 } 801 816 817 void Playlist::setBookmark(uint song, uint offset) 818 { 819 for (uint track = 0; track < songs.count(); track++) 820 if (songs.at(track) && songs.at(track)->getValue() == static_cast<int>(song)) 821 { 822 resume_song = song; 823 resume_offset = offset; 824 changed = true; 825 } 826 } 827 802 828 void Playlist::savePlaylist(QString a_name, QString a_host) 803 829 { 804 830 name = a_name.simplifyWhiteSpace(); … … 851 877 if (playlistid > 0) 852 878 { 853 879 QString str_query = "UPDATE music_playlists SET playlist_songs = :LIST," 854 " playlist_name = :NAME, songcount = :SONGCOUNT, length = :PLAYTIME"; 880 " playlist_name = :NAME, songcount = :SONGCOUNT, length = :PLAYTIME," 881 " resume_song = :BOOKMARKSONG, resume_offset = :BOOKMARKSONGOFFSET"; 855 882 if (save_host) 856 883 str_query += ", hostname = :HOSTNAME"; 857 884 str_query += " WHERE playlist_id = :ID ;"; … … 862 889 else 863 890 { 864 891 QString str_query = "INSERT INTO music_playlists" 865 " (playlist_name, playlist_songs, songcount, length ";892 " (playlist_name, playlist_songs, songcount, length, resume_song, resume_offset"; 866 893 if (save_host) 867 894 str_query += ", hostname"; 868 895 str_query += ") VALUES(:NAME, :LIST, :SONGCOUNT, :PLAYTIME"; 869 896 if (save_host) 870 897 str_query += ", :HOSTNAME"; 871 str_query += " );";898 str_query += ", :BOOKMARKSONG, :BOOKMARKSONGOFFSET);"; 872 899 873 900 query.prepare(str_query); 874 901 } … … 878 905 query.bindValue(":PLAYTIME", playtime); 879 906 if (save_host) 880 907 query.bindValue(":HOSTNAME", a_host); 908 query.bindValue(":BOOKMARKSONG", resume_song); 909 query.bindValue(":BOOKMARKSONGOFFSET", resume_offset); 881 910 882 911 if (!query.exec() || (playlistid < 1 && query.numRowsAffected() < 1)) 883 912 { -
mythmusic/mythmusic/playbackbox.h
135 135 SHUFFLE_ALBUM, 136 136 MAX_SHUFFLE_MODES 137 137 }; 138 enum ResumeMode 139 { RESUME_OFF, 140 RESUME_TRACK, 141 RESUME_EXACT, 142 MAX_RESUME_MODES 143 }; 138 144 139 145 bool listAsShuffled; 140 146 int outputBufferSize; … … 145 151 146 152 unsigned int shufflemode; 147 153 unsigned int repeatmode; 154 unsigned int resumemode; 148 155 149 156 bool isplaying; 150 157 bool lcd_volume_visible;