Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ | 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ |
| 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ | 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 class WebMediaPlayer; | 9 class WebMediaPlayer; |
| 10 } | 10 } |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 // An interface to allow a WebMediaPlayer to communicate changes of state to | 13 // An interface to allow a WebMediaPlayer to communicate changes of state to |
| 14 // objects that need to know. | 14 // objects that need to know. |
| 15 class WebMediaPlayerDelegate { | 15 class WebMediaPlayerDelegate { |
| 16 public: | 16 public: |
| 17 class Observer { | 17 class Observer { |
| 18 public: | 18 public: |
| 19 // Called when the WebMediaPlayer is no longer in the foreground. Audio may | 19 // Called when the WebMediaPlayer enters the background or foreground |
| 20 // continue in the background unless |must_suspend| is true. | 20 // respectively. Note: Some implementations will stop playback when hidden, |
| 21 virtual void OnHidden(bool must_suspend) = 0; | 21 // and thus subsequently call WebMediaPlayerDelegate::PlayerGone(). |
| 22 virtual void OnHidden() = 0; | |
| 23 virtual void OnShown() = 0; | |
| 22 | 24 |
| 23 virtual void OnShown() = 0; | 25 // Requests a WebMediaPlayer instance to release all idle resources. If |
| 26 // |must_suspend| is false, the player may ignore the request. However, if | |
| 27 // |must_suspend| is true, the player must stop playback, release all idle | |
| 28 // resources, and finally call WebMediaPlayerDelegate::PlayerGone(). | |
| 29 virtual void OnSuspendRequested(bool must_suspend) = 0; | |
|
xhwang
2016/03/10 21:51:06
One question for API. Is it legit that a WMP imple
DaleCurtis
2016/03/10 23:11:36
What case are you talking about? It seems your pro
xhwang
2016/03/11 00:09:19
Agreed that this is a hypothetical case.
As you s
DaleCurtis
2016/03/11 00:15:12
I think that's a correct assumption though :) Hidd
| |
| 30 | |
| 24 virtual void OnPlay() = 0; | 31 virtual void OnPlay() = 0; |
| 25 virtual void OnPause() = 0; | 32 virtual void OnPause() = 0; |
| 26 | 33 |
| 27 // Playout volume should be set to current_volume * multiplier. The range | 34 // Playout volume should be set to current_volume * multiplier. The range is |
| 28 // is [0, 1] and is typically 1. | 35 // [0, 1] and is typically 1. |
| 29 virtual void OnVolumeMultiplierUpdate(double multiplier) = 0; | 36 virtual void OnVolumeMultiplierUpdate(double multiplier) = 0; |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 WebMediaPlayerDelegate() {} | 39 WebMediaPlayerDelegate() {} |
| 33 | 40 |
| 34 // Subscribe or unsubscribe from observer callbacks respectively. A client | 41 // Subscribe or unsubscribe from observer callbacks respectively. A client |
| 35 // must use the delegate id returned by AddObserver() for all other calls. | 42 // must use the delegate id returned by AddObserver() for all other calls. |
| 36 virtual int AddObserver(Observer* observer) = 0; | 43 virtual int AddObserver(Observer* observer) = 0; |
| 37 virtual void RemoveObserver(int delegate_id) = 0; | 44 virtual void RemoveObserver(int delegate_id) = 0; |
| 38 | 45 |
| 39 // The specified player started playing media. | 46 // The specified player started playing media. |
| 40 virtual void DidPlay(int delegate_id, | 47 virtual void DidPlay(int delegate_id, |
| 41 bool has_video, | 48 bool has_video, |
| 42 bool has_audio, | 49 bool has_audio, |
| 43 bool is_remote, | 50 bool is_remote, |
| 44 base::TimeDelta duration) = 0; | 51 base::TimeDelta duration) = 0; |
| 45 | 52 |
| 46 // The specified player stopped playing media. | 53 // The specified player stopped playing media. |
| 47 virtual void DidPause(int delegate_id, bool reached_end_of_stream) = 0; | 54 virtual void DidPause(int delegate_id, bool reached_end_of_stream) = 0; |
| 48 | 55 |
| 49 // The specified player was destroyed or suspended. This may be called | 56 // The specified player was destroyed or suspended. This may be called |
| 50 // multiple times in row. Note: Clients must still call RemoveObserver() to | 57 // multiple times in row. Note: Clients must still call RemoveObserver() to |
| 51 // unsubscribe from callbacks. | 58 // unsubscribe from callbacks. |
| 52 virtual void PlayerGone(int delegate_id) = 0; | 59 virtual void PlayerGone(int delegate_id) = 0; |
| 53 | 60 |
| 54 // Returns whether the render frame is currently hidden. | 61 // Returns whether the render frame is currently hidden. |
| 55 virtual bool IsHidden() = 0; | 62 virtual bool IsHidden() = 0; |
| 56 | 63 |
| 57 protected: | 64 protected: |
| 58 virtual ~WebMediaPlayerDelegate() {} | 65 virtual ~WebMediaPlayerDelegate() {} |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 } // namespace media | 68 } // namespace media |
| 62 | 69 |
| 63 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ | 70 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ |
| OLD | NEW |