Ticket #1503: mediaplayer-volume-memory.diff
File mediaplayer-volume-memory.diff, 4.3 KB (added by , 15 years ago) |
---|
-
src/apps/mediaplayer/MainWin.cpp
587 587 PlaylistItemRef item(fPlaylist->ItemAt(index)); 588 588 if (item.Get() != NULL) { 589 589 printf("open playlist item: %s\n", item->Name().String()); 590 printf("\n ! Save current volume last played item\n"); 591 if (fLatestPlaylistItem != NULL) { 592 if (fLatestPlaylistItem->SetVolume(fController->Volume()) != B_OK) { 593 printf(" ! SetVolume failed."); 594 } else { 595 printf(" ! Volume set to %i", (int)fLatestPlaylistItem->Volume()); 596 } 597 } 590 598 OpenPlaylistItem(item); 599 fLatestPlaylistItem = fPlaylist->ItemAt(index); 600 printf("\n ! Load item volume\n"); 601 if (fLatestPlaylistItem->Volume() != -1) { 602 fController->SetVolume((float)fLatestPlaylistItem->Volume()); 603 printf(" ! Loading volume: %i", (int)fLatestPlaylistItem->Volume()); 604 } 591 605 _MarkPlaylistItem(index); 592 606 } 593 607 break; -
src/apps/mediaplayer/MainWin.h
152 152 bool fHasAudio; 153 153 154 154 Playlist* fPlaylist; 155 PlaylistItem* fLatestPlaylistItem; 155 156 PlaylistObserver* fPlaylistObserver; 156 157 Controller* fController; 157 158 ControllerObserver* fControllerObserver; -
src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
127 127 FilePlaylistItem::SetAttribute(const Attribute& attribute, 128 128 const int64& value) 129 129 { 130 if (attribute == ATTR_INT64_VOLUME) { 131 BNode node(&fRef); 132 return node.WriteAttr("mediaplayer:volume", B_INT64_TYPE, 0, &value, sizeof(value)); 133 } 134 130 135 return B_NOT_SUPPORTED; 131 136 } 132 137 … … 135 140 FilePlaylistItem::GetAttribute(const Attribute& attribute, 136 141 int64& value) const 137 142 { 143 if (attribute == ATTR_INT64_VOLUME) { 144 BNode node(&fRef); 145 return node.ReadAttr("mediaplayer:volume", B_INT64_TYPE, 0, &value, sizeof(value)); 146 } 147 138 148 return B_NOT_SUPPORTED; 139 149 } 140 150 … … 298 308 return new (std::nothrow) BMediaFile(&fRef); 299 309 } 300 310 311 312 status_t 313 FilePlaylistItem::SetVolume(int64 volume) 314 { 315 return SetAttribute(ATTR_INT64_VOLUME, volume); 316 } -
src/apps/mediaplayer/playlist/PlaylistItem.cpp
120 120 } 121 121 122 122 123 int64 124 PlaylistItem::Volume() const 125 { 126 int64 volume; 127 if (GetAttribute(ATTR_INT64_VOLUME, volume) != B_OK) 128 volume = -1; 129 return volume; 130 } 131 132 123 133 void 124 134 PlaylistItem::SetPlaybackFailed() 125 135 { -
src/apps/mediaplayer/playlist/PlaylistItem.h
50 50 ATTR_INT32_RATING = 'rtng', 51 51 ATTR_INT32_BIT_RATE = 'btrt', 52 52 53 ATTR_INT64_DURATION = 'drtn' 53 ATTR_INT64_DURATION = 'drtn', 54 55 ATTR_INT64_VOLUME = 'volu' 54 56 } Attribute; 55 57 56 58 virtual status_t SetAttribute(const Attribute& attribute, … … 79 81 80 82 bigtime_t Duration() const; 81 83 84 int64 Volume() const; 85 82 86 // methods 83 87 virtual BString LocationURI() const = 0; 84 88 virtual status_t GetIcon(BBitmap* bitmap, … … 87 91 virtual status_t MoveIntoTrash() = 0; 88 92 virtual status_t RestoreFromTrash() = 0; 89 93 94 virtual status_t SetVolume(int64 volume) = 0; 95 90 96 // playback 91 97 virtual BMediaFile* CreateMediaFile() const = 0; 92 98 -
src/apps/mediaplayer/playlist/FilePlaylistItem.h
47 47 virtual status_t MoveIntoTrash(); 48 48 virtual status_t RestoreFromTrash(); 49 49 50 virtual status_t SetVolume(int64 volume); 51 50 52 // playback 51 53 virtual BMediaFile* CreateMediaFile() const; 52 54