| 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 true, the player must stop playback, release all idle |
| 27 // resources, and finally call WebMediaPlayerDelegate::PlayerGone(). If |
| 28 // |must_suspend| is false, the player may ignore the request. Optionally, |
| 29 // it may do some or all of the same actions as when |must_suspend| is true. |
| 30 // To be clear, the player is not required to call PlayerGone() when |
| 31 // |must_suspend| is false. |
| 32 virtual void OnSuspendRequested(bool must_suspend) = 0; |
| 33 |
| 24 virtual void OnPlay() = 0; | 34 virtual void OnPlay() = 0; |
| 25 virtual void OnPause() = 0; | 35 virtual void OnPause() = 0; |
| 26 | 36 |
| 27 // Playout volume should be set to current_volume * multiplier. The range | 37 // Playout volume should be set to current_volume * multiplier. The range is |
| 28 // is [0, 1] and is typically 1. | 38 // [0, 1] and is typically 1. |
| 29 virtual void OnVolumeMultiplierUpdate(double multiplier) = 0; | 39 virtual void OnVolumeMultiplierUpdate(double multiplier) = 0; |
| 30 }; | 40 }; |
| 31 | 41 |
| 32 WebMediaPlayerDelegate() {} | 42 WebMediaPlayerDelegate() {} |
| 33 | 43 |
| 34 // Subscribe or unsubscribe from observer callbacks respectively. A client | 44 // Subscribe or unsubscribe from observer callbacks respectively. A client |
| 35 // must use the delegate id returned by AddObserver() for all other calls. | 45 // must use the delegate id returned by AddObserver() for all other calls. |
| 36 virtual int AddObserver(Observer* observer) = 0; | 46 virtual int AddObserver(Observer* observer) = 0; |
| 37 virtual void RemoveObserver(int delegate_id) = 0; | 47 virtual void RemoveObserver(int delegate_id) = 0; |
| 38 | 48 |
| 39 // The specified player started playing media. | 49 // The specified player started playing media. |
| 40 virtual void DidPlay(int delegate_id, | 50 virtual void DidPlay(int delegate_id, |
| 41 bool has_video, | 51 bool has_video, |
| 42 bool has_audio, | 52 bool has_audio, |
| 43 bool is_remote, | 53 bool is_remote, |
| 44 base::TimeDelta duration) = 0; | 54 base::TimeDelta duration) = 0; |
| 45 | 55 |
| 46 // The specified player stopped playing media. | 56 // The specified player stopped playing media. |
| 47 virtual void DidPause(int delegate_id, bool reached_end_of_stream) = 0; | 57 virtual void DidPause(int delegate_id, bool reached_end_of_stream) = 0; |
| 48 | 58 |
| 49 // The specified player was destroyed or suspended. This may be called | 59 // The specified player was destroyed or suspended and will no longer accept |
| 60 // Observer::OnPlay() or Observer::OnPause() calls. This may be called |
| 50 // multiple times in row. Note: Clients must still call RemoveObserver() to | 61 // multiple times in row. Note: Clients must still call RemoveObserver() to |
| 51 // unsubscribe from callbacks. | 62 // unsubscribe from callbacks. |
| 52 virtual void PlayerGone(int delegate_id) = 0; | 63 virtual void PlayerGone(int delegate_id) = 0; |
| 53 | 64 |
| 54 // Returns whether the render frame is currently hidden. | 65 // Returns whether the render frame is currently hidden. |
| 55 virtual bool IsHidden() = 0; | 66 virtual bool IsHidden() = 0; |
| 56 | 67 |
| 57 protected: | 68 protected: |
| 58 virtual ~WebMediaPlayerDelegate() {} | 69 virtual ~WebMediaPlayerDelegate() {} |
| 59 }; | 70 }; |
| 60 | 71 |
| 61 } // namespace media | 72 } // namespace media |
| 62 | 73 |
| 63 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ | 74 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ |
| OLD | NEW |