From 0d1d77c1ea3c2042ffebc70674761ace8ddc6f54 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Sat, 27 Sep 2014 00:29:09 +0200
Subject: [PATCH] Mediaplayer: remember position and volume
---
src/apps/mediaplayer/Controller.cpp | 59 +++++++++++++++++++
src/apps/mediaplayer/Controller.h | 4 ++
src/apps/mediaplayer/MainWin.cpp | 11 +++-
src/apps/mediaplayer/playlist/FilePlaylistItem.cpp | 66 +++++++++++++++++-----
src/apps/mediaplayer/playlist/FilePlaylistItem.h | 7 ++-
src/apps/mediaplayer/playlist/PlaylistItem.cpp | 38 ++++++++++++-
src/apps/mediaplayer/playlist/PlaylistItem.h | 16 +++++-
src/apps/mediaplayer/settings/Settings.cpp | 5 ++
src/apps/mediaplayer/settings/Settings.h | 6 ++
src/apps/mediaplayer/settings/SettingsWindow.cpp | 12 ++++
src/apps/mediaplayer/settings/SettingsWindow.h | 1 +
11 files changed, 206 insertions(+), 19 deletions(-)
diff --git a/src/apps/mediaplayer/Controller.cpp b/src/apps/mediaplayer/Controller.cpp
index 5176a3d..516380f 100644
a
|
b
|
|
29 | 29 | |
30 | 30 | #include <Autolock.h> |
31 | 31 | #include <Bitmap.h> |
| 32 | #include <Catalog.h> |
32 | 33 | #include <Debug.h> |
33 | 34 | #include <Path.h> |
34 | 35 | #include <Window.h> // for debugging only |
… |
… |
|
50 | 51 | #include "TrackSupplier.h" |
51 | 52 | #include "VideoTrackSupplier.h" |
52 | 53 | |
| 54 | #undef B_TRANSLATION_CONTEXT |
| 55 | #define B_TRANSLATION_CONTEXT "MediaPlayer-Controller" |
| 56 | #define MIN_WIDTH 250 |
| 57 | |
53 | 58 | using std::nothrow; |
54 | 59 | |
55 | 60 | |
… |
… |
Controller::TimePosition()
|
680 | 685 | } |
681 | 686 | |
682 | 687 | |
| 688 | status_t |
| 689 | Controller::SaveState(bool reset) |
| 690 | { |
| 691 | if (fItem.Get() == NULL) |
| 692 | return B_OK; |
| 693 | if (reset) |
| 694 | fCurrentFrame = 0; |
| 695 | status_t status = fItem.Get()->SetLastVolume(fVolume); |
| 696 | if (status == B_OK) |
| 697 | status = fItem.Get()->SetLastFrame(fCurrentFrame); |
| 698 | else |
| 699 | fItem.Get()->SetLastFrame(fCurrentFrame); |
| 700 | return status; |
| 701 | } |
| 702 | |
| 703 | |
| 704 | void |
| 705 | Controller::RestoreState() |
| 706 | { |
| 707 | PlaylistItem *item =fItem.Get(); |
| 708 | if (item == NULL) |
| 709 | return; |
| 710 | |
| 711 | Pause(); |
| 712 | |
| 713 | if (item->LastFrame() > 0) { |
| 714 | bool resume = fResume == mpSettings::RESUME_ALWAYS; |
| 715 | if (fResume == mpSettings::RESUME_ASK) { |
| 716 | BString label; |
| 717 | int32 time = (int32)((float)item->LastFrame() * TimeDuration() |
| 718 | / (1000000 * _FrameDuration())); |
| 719 | label.SetToFormat(B_TRANSLATE("Do you want to resume %s at %dm%ds?"), |
| 720 | item->Name().String(), time / 60, time % 60); |
| 721 | BAlert *alert = new BAlert(B_TRANSLATE("Resume?"), label, |
| 722 | B_TRANSLATE("Resume"), B_TRANSLATE("Reset")); |
| 723 | resume = alert->Go() == 0; |
| 724 | } |
| 725 | |
| 726 | if (resume) |
| 727 | SetFramePosition(item->LastFrame()); |
| 728 | } |
| 729 | |
| 730 | float lastVolume = item->LastVolume(); |
| 731 | if (lastVolume >= 0) |
| 732 | SetVolume(lastVolume); |
| 733 | |
| 734 | Play(); |
| 735 | } |
| 736 | |
| 737 | |
683 | 738 | void |
684 | 739 | Controller::SetVolume(float value) |
685 | 740 | { |
… |
… |
Controller::SetVolume(float value)
|
699 | 754 | } |
700 | 755 | } |
701 | 756 | |
| 757 | |
702 | 758 | void |
703 | 759 | Controller::VolumeUp() |
704 | 760 | { |
… |
… |
Controller::VolumeUp()
|
706 | 762 | SetVolume(Volume() + 0.05); |
707 | 763 | } |
708 | 764 | |
| 765 | |
709 | 766 | void |
710 | 767 | Controller::VolumeDown() |
711 | 768 | { |
… |
… |
Controller::VolumeDown()
|
713 | 770 | SetVolume(Volume() - 0.05); |
714 | 771 | } |
715 | 772 | |
| 773 | |
716 | 774 | void |
717 | 775 | Controller::ToggleMute() |
718 | 776 | { |
… |
… |
Controller::_AdoptGlobalSettings()
|
974 | 1032 | fLoopMovies = settings.loopMovie; |
975 | 1033 | fLoopSounds = settings.loopSound; |
976 | 1034 | fBackgroundMovieVolumeMode = settings.backgroundMovieVolumeMode; |
| 1035 | fResume = settings.resume; |
977 | 1036 | } |
978 | 1037 | |
979 | 1038 | |
diff --git a/src/apps/mediaplayer/Controller.h b/src/apps/mediaplayer/Controller.h
index 1eeda17..451d55a 100644
a
|
b
|
|
22 | 22 | #define __CONTROLLER_H |
23 | 23 | |
24 | 24 | |
| 25 | #include <Alert.h> |
25 | 26 | #include <Entry.h> |
26 | 27 | #include <MediaDefs.h> |
27 | 28 | #include <MediaFormats.h> |
… |
… |
public:
|
115 | 116 | |
116 | 117 | bigtime_t TimeDuration(); |
117 | 118 | bigtime_t TimePosition(); |
| 119 | status_t SaveState(bool reset = false); |
| 120 | void RestoreState(); |
118 | 121 | |
119 | 122 | virtual void SetVolume(float factor); |
120 | 123 | float Volume(); |
… |
… |
private:
|
224 | 227 | bool fLoopMovies; |
225 | 228 | bool fLoopSounds; |
226 | 229 | uint32 fBackgroundMovieVolumeMode; |
| 230 | uint32 fResume; |
227 | 231 | |
228 | 232 | BList fListeners; |
229 | 233 | }; |
diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp
index 3229867..f5eb7e7 100644
a
|
b
|
MainWin::MessageReceived(BMessage* msg)
|
697 | 697 | { |
698 | 698 | BAutolock _(fPlaylist); |
699 | 699 | |
| 700 | //The file is finished. Open at start next time. |
| 701 | fController->SaveState(true); |
| 702 | |
700 | 703 | bool hadNext = fPlaylist->SetCurrentItemIndex( |
701 | 704 | fPlaylist->CurrentItemIndex() + 1); |
702 | 705 | if (!hadNext) { |
… |
… |
MainWin::MessageReceived(BMessage* msg)
|
799 | 802 | float volume; |
800 | 803 | if (msg->FindFloat("volume", &volume) == B_OK) |
801 | 804 | fControls->SetVolume(volume); |
| 805 | fController->SaveState(); |
802 | 806 | break; |
803 | 807 | } |
804 | 808 | case MSG_CONTROLLER_MUTED_CHANGED: |
… |
… |
MainWin::WindowActivated(bool active)
|
1067 | 1071 | bool |
1068 | 1072 | MainWin::QuitRequested() |
1069 | 1073 | { |
| 1074 | fController->SaveState(); |
1070 | 1075 | BMessage message(M_PLAYER_QUIT); |
1071 | 1076 | GetQuitMessage(&message); |
1072 | 1077 | be_app->PostMessage(&message); |
… |
… |
MainWin::_PlaylistItemOpened(const PlaylistItemRef& item, status_t result)
|
1401 | 1406 | } |
1402 | 1407 | fController->SetTimePosition(fInitialSeekPosition); |
1403 | 1408 | fInitialSeekPosition = 0; |
| 1409 | |
| 1410 | if (fPlaylist->CountItems() == 1) |
| 1411 | fController->RestoreState(); |
1404 | 1412 | } |
1405 | 1413 | _SetupWindow(); |
1406 | 1414 | |
… |
… |
MainWin::_Wind(bigtime_t howMuch, int64 frames)
|
2452 | 2460 | } else if (seekTime > fController->TimeDuration()) { |
2453 | 2461 | fInitialSeekPosition = 0; |
2454 | 2462 | PostMessage(M_SKIP_NEXT); |
2455 | | } else |
| 2463 | } else { |
2456 | 2464 | fController->SetTimePosition(seekTime); |
| 2465 | } |
2457 | 2466 | } |
2458 | 2467 | |
2459 | 2468 | fController->Unlock(); |
diff --git a/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp b/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
index 4b1cafd..5b5e430 100644
a
|
b
|
FilePlaylistItem::SetAttribute(const Attribute& attribute,
|
114 | 114 | BEntry entry(&fRefs[0], false); |
115 | 115 | return entry.Rename(string.String(), false); |
116 | 116 | } |
117 | | |
| 117 | |
118 | 118 | case ATTR_STRING_KEYWORDS: |
119 | 119 | return _SetAttribute("Meta:Keywords", B_STRING_TYPE, |
120 | 120 | string.String(), string.Length()); |
… |
… |
status_t
|
190 | 190 | FilePlaylistItem::SetAttribute(const Attribute& attribute, |
191 | 191 | const int64& value) |
192 | 192 | { |
| 193 | if (attribute == ATTR_INT64_FRAME) { |
| 194 | return _SetAttribute("Media:Frame", B_INT64_TYPE, &value, |
| 195 | sizeof(int64)); |
| 196 | } |
| 197 | |
193 | 198 | return B_NOT_SUPPORTED; |
194 | 199 | } |
195 | 200 | |
… |
… |
status_t
|
198 | 203 | FilePlaylistItem::GetAttribute(const Attribute& attribute, |
199 | 204 | int64& value) const |
200 | 205 | { |
| 206 | if (attribute == ATTR_INT64_FRAME) { |
| 207 | return _GetAttribute("Media:Frame", B_INT64_TYPE, &value, |
| 208 | sizeof(int64)); |
| 209 | } |
| 210 | |
| 211 | return B_NOT_SUPPORTED; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | status_t |
| 216 | FilePlaylistItem::SetAttribute(const Attribute& attribute, |
| 217 | const float& value) |
| 218 | { |
| 219 | if (attribute == ATTR_FLOAT_VOLUME) { |
| 220 | return _SetAttribute("Media:Volume", B_FLOAT_TYPE, &value, |
| 221 | sizeof(float)); |
| 222 | } |
| 223 | |
| 224 | return B_NOT_SUPPORTED; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | status_t |
| 229 | FilePlaylistItem::GetAttribute(const Attribute& attribute, |
| 230 | float& value) const |
| 231 | { |
| 232 | if (attribute == ATTR_FLOAT_VOLUME) { |
| 233 | return _GetAttribute("Media:Volume", B_FLOAT_TYPE, &value, |
| 234 | sizeof(float)); |
| 235 | } |
| 236 | |
201 | 237 | return B_NOT_SUPPORTED; |
202 | 238 | } |
203 | 239 | |
… |
… |
FilePlaylistItem::MoveIntoTrash()
|
236 | 272 | err = _MoveIntoTrash(&fRefs, &fNamesInTrash); |
237 | 273 | if (err != B_OK) |
238 | 274 | return err; |
239 | | |
| 275 | |
240 | 276 | if (fImageRefs.empty()) |
241 | 277 | return B_OK; |
242 | 278 | |
… |
… |
FilePlaylistItem::RestoreFromTrash()
|
260 | 296 | err = _RestoreFromTrash(&fRefs, &fNamesInTrash); |
261 | 297 | if (err != B_OK) |
262 | 298 | return err; |
263 | | |
| 299 | |
264 | 300 | if (fImageRefs.empty()) |
265 | 301 | return B_OK; |
266 | 302 | |
… |
… |
FilePlaylistItem::ImageRef() const
|
381 | 417 | |
382 | 418 | if (fImageRefs.empty()) |
383 | 419 | return ref; |
384 | | |
| 420 | |
385 | 421 | return fImageRefs[0]; |
386 | 422 | } |
387 | 423 | |
… |
… |
FilePlaylistItem::_SetAttribute(const char* attrName, type_code type,
|
407 | 443 | |
408 | 444 | status_t |
409 | 445 | FilePlaylistItem::_GetAttribute(const char* attrName, type_code type, |
410 | | void* data, size_t size) |
| 446 | void* data, size_t size) const |
411 | 447 | { |
412 | 448 | BEntry entry(&fRefs[0], true); |
413 | 449 | BNode node(&entry); |
… |
… |
FilePlaylistItem::_MoveIntoTrash(vector<entry_ref>* refs,
|
452 | 488 | (*refs)[i].name, strerror(err)); |
453 | 489 | return err; |
454 | 490 | } |
455 | | |
| 491 | |
456 | 492 | // Find a unique name for the entry in the trash |
457 | 493 | (*namesInTrash)[i] = (*refs)[i].name; |
458 | 494 | int32 uniqueNameIndex = 1; |
… |
… |
FilePlaylistItem::_MoveIntoTrash(vector<entry_ref>* refs,
|
464 | 500 | (*namesInTrash)[i] << ' ' << uniqueNameIndex; |
465 | 501 | uniqueNameIndex++; |
466 | 502 | } |
467 | | |
| 503 | |
468 | 504 | // Remember the original path |
469 | 505 | BPath originalPath; |
470 | 506 | entry.GetPath(&originalPath); |
471 | | |
| 507 | |
472 | 508 | // Finally, move the entry into the trash |
473 | 509 | err = entry.MoveTo(&trashDir, (*namesInTrash)[i].String()); |
474 | 510 | if (err != B_OK) { |
… |
… |
FilePlaylistItem::_MoveIntoTrash(vector<entry_ref>* refs,
|
476 | 512 | trashPath, strerror(err)); |
477 | 513 | return err; |
478 | 514 | } |
479 | | |
| 515 | |
480 | 516 | // Allow Tracker to restore this entry |
481 | 517 | BNode node(&entry); |
482 | 518 | BString originalPathString(originalPath.Path()); |
… |
… |
FilePlaylistItem::_RestoreFromTrash(vector<entry_ref>* refs,
|
498 | 534 | fprintf(stderr, "failed to find Trash: %s\n", strerror(err)); |
499 | 535 | return err; |
500 | 536 | } |
501 | | |
| 537 | |
502 | 538 | for (vector<entry_ref>::size_type i = 0; i < refs->size(); i++) { |
503 | 539 | // construct the entry to the file in the trash |
504 | 540 | // TODO: BEntry(const BDirectory* directory, const char* path) is broken! |
… |
… |
FilePlaylistItem::_RestoreFromTrash(vector<entry_ref>* refs,
|
513 | 549 | } |
514 | 550 | //entry.GetPath(&path); |
515 | 551 | //printf("moving '%s'\n", path.Path()); |
516 | | |
| 552 | |
517 | 553 | // construct the folder of the original entry_ref |
518 | 554 | node_ref nodeRef; |
519 | 555 | nodeRef.device = (*refs)[i].device; |
… |
… |
FilePlaylistItem::_RestoreFromTrash(vector<entry_ref>* refs,
|
525 | 561 | "%s: %s\n", (*refs)[i].name, strerror(err)); |
526 | 562 | return err; |
527 | 563 | } |
528 | | |
| 564 | |
529 | 565 | //path.SetTo(&originalDir, fItems[i].name); |
530 | 566 | //printf("as '%s'\n", path.Path()); |
531 | | |
| 567 | |
532 | 568 | // Reset the name here, the user may have already moved the entry |
533 | 569 | // out of the trash via Tracker for example. |
534 | 570 | (*namesInTrash)[i] = ""; |
535 | | |
| 571 | |
536 | 572 | // Finally, move the entry back into the original folder |
537 | 573 | err = entry.MoveTo(&originalDir, (*refs)[i].name); |
538 | 574 | if (err != B_OK) { |
… |
… |
FilePlaylistItem::_RestoreFromTrash(vector<entry_ref>* refs,
|
540 | 576 | "%s: %s\n", (*refs)[i].name, strerror(err)); |
541 | 577 | return err; |
542 | 578 | } |
543 | | |
| 579 | |
544 | 580 | // Remove the attribute that helps Tracker restore the entry. |
545 | 581 | BNode node(&entry); |
546 | 582 | node.RemoveAttr("_trk/original_path"); |
diff --git a/src/apps/mediaplayer/playlist/FilePlaylistItem.h b/src/apps/mediaplayer/playlist/FilePlaylistItem.h
index a0c4da4..126cf78 100644
a
|
b
|
public:
|
43 | 43 | const int64& value); |
44 | 44 | virtual status_t GetAttribute(const Attribute& attribute, |
45 | 45 | int64& value) const; |
| 46 | |
| 47 | virtual status_t SetAttribute(const Attribute& attribute, |
| 48 | const float& value); |
| 49 | virtual status_t GetAttribute(const Attribute& attribute, |
| 50 | float& value) const; |
46 | 51 | |
47 | 52 | // methods |
48 | 53 | virtual BString LocationURI() const; |
… |
… |
private:
|
67 | 72 | size_t size); |
68 | 73 | status_t _GetAttribute(const char* attrName, |
69 | 74 | type_code type, void* data, |
70 | | size_t size); |
| 75 | size_t size) const; |
71 | 76 | status_t _MoveIntoTrash(vector<entry_ref>* refs, |
72 | 77 | vector<BString>* namesInTrash); |
73 | 78 | status_t _RestoreFromTrash(vector<entry_ref>* refs, |
diff --git a/src/apps/mediaplayer/playlist/PlaylistItem.cpp b/src/apps/mediaplayer/playlist/PlaylistItem.cpp
index fde90a8..6bbe0e3 100644
a
|
b
|
PlaylistItem::Listener::Listener()
|
19 | 19 | { |
20 | 20 | } |
21 | 21 | |
| 22 | |
22 | 23 | PlaylistItem::Listener::~Listener() |
23 | 24 | { |
24 | 25 | } |
25 | 26 | |
| 27 | |
26 | 28 | void PlaylistItem::Listener::ItemChanged(const PlaylistItem* item) |
27 | 29 | { |
28 | 30 | } |
… |
… |
void PlaylistItem::Listener::ItemChanged(const PlaylistItem* item)
|
31 | 33 | // #pragma mark - |
32 | 34 | |
33 | 35 | |
34 | | //#define DEBUG_INSTANCE_COUNT |
| 36 | // #define DEBUG_INSTANCE_COUNT |
35 | 37 | #ifdef DEBUG_INSTANCE_COUNT |
36 | 38 | static vint32 sInstanceCount = 0; |
37 | 39 | #endif |
… |
… |
PlaylistItem::TrackNumber() const
|
107 | 109 | } |
108 | 110 | |
109 | 111 | |
| 112 | int64 |
| 113 | PlaylistItem::LastFrame() const |
| 114 | { |
| 115 | int64 lastFrame; |
| 116 | if (GetAttribute(ATTR_INT64_FRAME, lastFrame) != B_OK) |
| 117 | lastFrame = 0; |
| 118 | return lastFrame; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | float |
| 123 | PlaylistItem::LastVolume() const |
| 124 | { |
| 125 | float lastVolume; |
| 126 | if (GetAttribute(ATTR_FLOAT_VOLUME, lastVolume) != B_OK) |
| 127 | lastVolume = -1; |
| 128 | return lastVolume; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | status_t |
| 133 | PlaylistItem::SetLastFrame(int64 value) |
| 134 | { |
| 135 | return SetAttribute(ATTR_INT64_FRAME, value); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | status_t |
| 140 | PlaylistItem::SetLastVolume(float value) |
| 141 | { |
| 142 | return SetAttribute(ATTR_FLOAT_VOLUME, value); |
| 143 | } |
| 144 | |
| 145 | |
110 | 146 | void |
111 | 147 | PlaylistItem::SetPlaybackFailed() |
112 | 148 | { |
diff --git a/src/apps/mediaplayer/playlist/PlaylistItem.h b/src/apps/mediaplayer/playlist/PlaylistItem.h
index b896df5..a34f9a7 100644
a
|
b
|
public:
|
53 | 53 | |
54 | 54 | ATTR_INT32_TRACK = 'trck', |
55 | 55 | ATTR_INT32_YEAR = 'year', |
56 | | ATTR_INT32_RATING = 'rtng' |
| 56 | ATTR_INT32_RATING = 'rtng', |
| 57 | |
| 58 | ATTR_INT64_FRAME = 'fram', |
| 59 | |
| 60 | ATTR_FLOAT_VOLUME = 'volu' |
57 | 61 | } Attribute; |
58 | 62 | |
59 | 63 | virtual status_t SetAttribute(const Attribute& attribute, |
… |
… |
public:
|
70 | 74 | const int64& value) = 0; |
71 | 75 | virtual status_t GetAttribute(const Attribute& attribute, |
72 | 76 | int64& value) const = 0; |
| 77 | |
| 78 | virtual status_t SetAttribute(const Attribute& attribute, |
| 79 | const float& value) = 0; |
| 80 | virtual status_t GetAttribute(const Attribute& attribute, |
| 81 | float& value) const = 0; |
73 | 82 | |
74 | 83 | // convenience access to attributes |
75 | 84 | BString Name() const; |
… |
… |
public:
|
78 | 87 | BString Title() const; |
79 | 88 | |
80 | 89 | int32 TrackNumber() const; |
| 90 | int64 LastFrame() const; |
| 91 | float LastVolume() const; |
| 92 | |
| 93 | status_t SetLastFrame(int64 value); |
| 94 | status_t SetLastVolume(float value); |
81 | 95 | |
82 | 96 | // methods |
83 | 97 | virtual BString LocationURI() const = 0; |
diff --git a/src/apps/mediaplayer/settings/Settings.cpp b/src/apps/mediaplayer/settings/Settings.cpp
index 7f1d00d..a4b22f9 100644
a
|
b
|
mpSettings::operator!=(const mpSettings& other) const
|
26 | 26 | || useOverlays != other.useOverlays |
27 | 27 | || scaleBilinear != other.scaleBilinear |
28 | 28 | || scaleFullscreenControls != other.scaleFullscreenControls |
| 29 | || resume != other.resume |
29 | 30 | || subtitleSize != other.subtitleSize |
30 | 31 | || subtitlePlacement != other.subtitlePlacement |
31 | 32 | || backgroundMovieVolumeMode != other.backgroundMovieVolumeMode |
… |
… |
Settings::Get(mpSettings& settings) const
|
61 | 62 | settings.scaleFullscreenControls |
62 | 63 | = fSettingsMessage.GetValue("scaleFullscreenControls", true); |
63 | 64 | |
| 65 | settings.resume |
| 66 | = fSettingsMessage.GetValue("resume", |
| 67 | (uint32)mpSettings::RESUME_ASK); |
64 | 68 | settings.subtitleSize |
65 | 69 | = fSettingsMessage.GetValue("subtitleSize", |
66 | 70 | (uint32)mpSettings::SUBTITLE_SIZE_MEDIUM); |
… |
… |
Settings::Update(const mpSettings& settings)
|
95 | 99 | fSettingsMessage.SetValue("scaleFullscreenControls", |
96 | 100 | settings.scaleFullscreenControls); |
97 | 101 | |
| 102 | fSettingsMessage.SetValue("resume", settings.resume); |
98 | 103 | fSettingsMessage.SetValue("subtitleSize", settings.subtitleSize); |
99 | 104 | fSettingsMessage.SetValue("subtitlePlacement", settings.subtitlePlacement); |
100 | 105 | |
diff --git a/src/apps/mediaplayer/settings/Settings.h b/src/apps/mediaplayer/settings/Settings.h
index f8b3590..5dbc499 100644
a
|
b
|
struct mpSettings {
|
34 | 34 | BG_MOVIES_HALF_VLUME = 1, |
35 | 35 | BG_MOVIES_MUTED = 2 |
36 | 36 | }; |
| 37 | enum { |
| 38 | RESUME_NEVER = 0, |
| 39 | RESUME_ASK = 1, |
| 40 | RESUME_ALWAYS = 2 |
| 41 | }; |
37 | 42 | |
38 | 43 | bool autostart; |
39 | 44 | bool closeWhenDonePlayingMovie; |
… |
… |
struct mpSettings {
|
43 | 48 | bool useOverlays; |
44 | 49 | bool scaleBilinear; |
45 | 50 | bool scaleFullscreenControls; |
| 51 | uint32 resume; |
46 | 52 | uint32 subtitleSize; |
47 | 53 | uint32 subtitlePlacement; |
48 | 54 | uint32 backgroundMovieVolumeMode; |
diff --git a/src/apps/mediaplayer/settings/SettingsWindow.cpp b/src/apps/mediaplayer/settings/SettingsWindow.cpp
index ea1cc17..d3eaa62 100644
a
|
b
|
SettingsWindow::SettingsWindow(BRect frame)
|
99 | 99 | B_TRANSLATE("Scale controls in full screen mode"), |
100 | 100 | new BMessage(M_SETTINGS_CHANGED)); |
101 | 101 | |
| 102 | fResumeOP = new BOptionPopUp("resume", |
| 103 | B_TRANSLATE("Resume:"), new BMessage(M_SETTINGS_CHANGED)); |
| 104 | fResumeOP->AddOption( |
| 105 | B_TRANSLATE("never"), mpSettings::RESUME_NEVER); |
| 106 | fResumeOP->AddOption( |
| 107 | B_TRANSLATE("ask every time"), mpSettings::RESUME_ASK); |
| 108 | fResumeOP->AddOption( |
| 109 | B_TRANSLATE("always"), mpSettings::RESUME_ALWAYS); |
| 110 | |
102 | 111 | fSubtitleSizeOP = new BOptionPopUp("subtitleSize", |
103 | 112 | B_TRANSLATE("Subtitle size:"), new BMessage(M_SETTINGS_CHANGED)); |
104 | 113 | fSubtitleSizeOP->AddOption( |
… |
… |
SettingsWindow::SettingsWindow(BRect frame)
|
156 | 165 | .End() |
157 | 166 | .Add(fLoopMoviesCB) |
158 | 167 | .Add(fLoopSoundsCB) |
| 168 | .Add(fResumeOP) |
159 | 169 | .End() |
160 | 170 | .End() |
161 | 171 | .AddStrut(kSpacing) |
… |
… |
SettingsWindow::AdoptSettings()
|
270 | 280 | fScaleBilinearCB->SetValue(fSettings.scaleBilinear); |
271 | 281 | fScaleFullscreenControlsCB->SetValue(fSettings.scaleFullscreenControls); |
272 | 282 | |
| 283 | fResumeOP->SetValue(fSettings.resume); |
273 | 284 | fSubtitleSizeOP->SetValue(fSettings.subtitleSize); |
274 | 285 | fSubtitlePlacementOP->SetValue(fSettings.subtitlePlacement); |
275 | 286 | |
… |
… |
SettingsWindow::ApplySettings()
|
300 | 311 | fSettings.scaleFullscreenControls |
301 | 312 | = fScaleFullscreenControlsCB->Value() == B_CONTROL_ON; |
302 | 313 | |
| 314 | fSettings.resume = fResumeOP->Value(); |
303 | 315 | fSettings.subtitleSize = fSubtitleSizeOP->Value(); |
304 | 316 | fSettings.subtitlePlacement = fSubtitlePlacementOP->Value(); |
305 | 317 | |
diff --git a/src/apps/mediaplayer/settings/SettingsWindow.h b/src/apps/mediaplayer/settings/SettingsWindow.h
index 6285620..312927a 100644
a
|
b
|
private:
|
47 | 47 | BCheckBox* fScaleBilinearCB; |
48 | 48 | BCheckBox* fScaleFullscreenControlsCB; |
49 | 49 | |
| 50 | BOptionPopUp* fResumeOP; |
50 | 51 | BOptionPopUp* fSubtitleSizeOP; |
51 | 52 | BOptionPopUp* fSubtitlePlacementOP; |
52 | 53 | |