summaryrefslogtreecommitdiffstats
path: root/media/player/seek.h
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 19:52:35 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 19:52:35 +0000
commitf70de8a744fc70811bfb5a9c8202505f9f43ff8a (patch)
tree899d6d4a8b863e83887a78982c5d8843409e7c68 /media/player/seek.h
parent0cb941091a7bd3ae1fbb909330d73001afa7f5f3 (diff)
downloadchromium_src-f70de8a744fc70811bfb5a9c8202505f9f43ff8a.zip
chromium_src-f70de8a744fc70811bfb5a9c8202505f9f43ff8a.tar.gz
chromium_src-f70de8a744fc70811bfb5a9c8202505f9f43ff8a.tar.bz2
Media player adds seek menu and dialog.
Review URL: http://codereview.chromium.org/115692 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16778 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/player/seek.h')
-rw-r--r--media/player/seek.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/media/player/seek.h b/media/player/seek.h
new file mode 100644
index 0000000..1899ce0
--- /dev/null
+++ b/media/player/seek.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+// seek.h : movie seek dialog
+
+#ifndef MEDIA_PLAYER_SEEK_H_
+#define MEDIA_PLAYER_SEEK_H_
+
+// TODO(fbachard): Frame properties only work for images, so
+// this tab is removed until movie frame properties can be added.
+class CSeek : public CSimpleDialog<IDD_SEEK>,
+ public CMessageFilter,
+ public CIdleHandler {
+ public:
+
+ CSeek() {
+ }
+
+ virtual BOOL PreTranslateMessage(MSG* pMsg) {
+ return FALSE;
+ }
+
+ BEGIN_MSG_MAP(CSeek)
+ MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
+ MESSAGE_HANDLER(WM_PAINT, OnPaint)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ CHAIN_MSG_MAP(CSimpleDialog<IDD_SEEK>)
+ END_MSG_MAP()
+
+ LRESULT OnPaint(UINT /*uMsg*/,
+ WPARAM /*wParam*/,
+ LPARAM /*lParam*/,
+ BOOL& bHandled) {
+ static float previous_position = -1.0f;
+
+ float position = media::Movie::get()->GetPosition();
+ if (static_cast<int>(position * 10) !=
+ static_cast<int>(previous_position * 10)) {
+ previous_position = position;
+ wchar_t szBuff[200];
+ float duration = media::Movie::get()->GetDuration();
+ float fps = 29.97f;
+ wsprintf(szBuff, L"%i.%i / %i.%i, %i / %i",
+ static_cast<int>(position),
+ static_cast<int>(position * 10) % 10,
+ static_cast<int>(duration),
+ static_cast<int>(duration * 10) % 10,
+ static_cast<int>(position * fps),
+ static_cast<int>(duration * fps));
+ SetDlgItemText(IDC_SEEKLOCATION, szBuff);
+ bHandled = TRUE;
+ return FALSE;
+ }
+ bHandled = FALSE;
+ return FALSE;
+ }
+
+ virtual BOOL OnIdle() {
+ wchar_t szBuff[200];
+ float position = media::Movie::get()->GetPosition();
+ float duration = media::Movie::get()->GetDuration();
+ // TODO(fbarchard): Use frame rate property when it exists.
+ float fps = 29.97f;
+ wsprintf(szBuff, L"%i.%i / %i.%i, %i / %i",
+ static_cast<int>(position),
+ static_cast<int>(position * 10) % 10,
+ static_cast<int>(duration),
+ static_cast<int>(duration * 10) % 10,
+ static_cast<int>(position * fps),
+ static_cast<int>(duration * fps));
+ SetDlgItemText(IDC_SEEKLOCATION, szBuff);
+ return FALSE;
+ }
+
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
+ BOOL& /*bHandled*/) {
+ CMessageLoop* pLoop = g_module.GetMessageLoop();
+ ATLASSERT(pLoop != NULL);
+ pLoop->AddMessageFilter(this);
+ pLoop->AddIdleHandler(this);
+ return TRUE;
+ }
+
+ LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
+ BOOL& bHandled) {
+ // unregister message filtering and idle updates
+ CMessageLoop* pLoop = g_module.GetMessageLoop();
+ ATLASSERT(pLoop != NULL);
+ pLoop->RemoveMessageFilter(this);
+ pLoop->RemoveIdleHandler(this);
+ bHandled = FALSE;
+ return 1;
+ }
+};
+
+#endif // MEDIA_PLAYER_SEEK_H_
+