| 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 WebMediaPlayerImpl to communicate changes of state | 13 // An interface to allow a WebMediaPlayerImpl to communicate changes of state |
| 14 // to objects that need to know. | 14 // to 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 virtual void OnHidden() = 0; | 19 virtual void OnHidden() = 0; |
| 20 virtual void OnShown() = 0; | 20 virtual void OnShown() = 0; |
| 21 virtual void OnPlay() = 0; |
| 22 virtual void OnPause() = 0; |
| 21 }; | 23 }; |
| 22 | 24 |
| 23 WebMediaPlayerDelegate() {} | 25 WebMediaPlayerDelegate() {} |
| 24 | 26 |
| 27 // Subscribe to observer callbacks. Must be called in order to use any of the |
| 28 // other methods. |
| 29 virtual void AddObserver(Observer* observer) = 0; |
| 30 |
| 25 // The specified player started playing media. | 31 // The specified player started playing media. |
| 26 virtual void DidPlay(blink::WebMediaPlayer* player) = 0; | 32 virtual void DidPlay(Observer* observer, |
| 33 bool has_video, |
| 34 bool has_audio, |
| 35 bool is_remote, |
| 36 base::TimeDelta duration) = 0; |
| 27 | 37 |
| 28 // The specified player stopped playing media. | 38 // The specified player stopped playing media. |
| 29 virtual void DidPause(blink::WebMediaPlayer* player) = 0; | 39 virtual void DidPause(Observer* observer, bool reached_end_of_stream) = 0; |
| 30 | 40 |
| 31 // The specified player was destroyed. Do not call any methods on it. | 41 // The specified player was destroyed. Removes the observer from any future |
| 32 // (RemoveObserver() is still necessary if the player is also an observer.) | 42 // notifications. Do not call any methods on it. |
| 33 virtual void PlayerGone(blink::WebMediaPlayer* player) = 0; | 43 virtual void PlayerGone(Observer* observer) = 0; |
| 34 | |
| 35 // Subscribe to observer callbacks. | |
| 36 virtual void AddObserver(Observer* observer) = 0; | |
| 37 | |
| 38 // Unsubscribe from observer callbacks. | |
| 39 virtual void RemoveObserver(Observer* observer) = 0; | |
| 40 | 44 |
| 41 // Returns whether the render frame is currently hidden. | 45 // Returns whether the render frame is currently hidden. |
| 42 virtual bool IsHidden() = 0; | 46 virtual bool IsHidden() = 0; |
| 43 | 47 |
| 44 protected: | 48 protected: |
| 45 virtual ~WebMediaPlayerDelegate() {} | 49 virtual ~WebMediaPlayerDelegate() {} |
| 46 }; | 50 }; |
| 47 | 51 |
| 48 } // namespace media | 52 } // namespace media |
| 49 | 53 |
| 50 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ | 54 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_DELEGATE_H_ |
| OLD | NEW |