| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/media/android/webmediaplayer_impl_android.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/logging.h" |
| 9 #include "media/base/android/media_player_bridge.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.
h" |
| 12 #include "webkit/media/android/stream_texture_factory_android.h" |
| 13 #include "webkit/media/android/webmediaplayer_manager_android.h" |
| 14 #include "webkit/media/android/webmediaplayer_proxy_android.h" |
| 15 |
| 16 using WebKit::WebMediaPlayerClient; |
| 17 using WebKit::WebMediaPlayer; |
| 18 |
| 19 namespace webkit_media { |
| 20 |
| 21 WebMediaPlayerImplAndroid::WebMediaPlayerImplAndroid( |
| 22 WebKit::WebFrame* frame, |
| 23 WebMediaPlayerClient* client, |
| 24 WebMediaPlayerManagerAndroid* manager, |
| 25 WebMediaPlayerProxyAndroid* proxy, |
| 26 StreamTextureFactory* factory) |
| 27 : WebMediaPlayerAndroid(client, manager, factory), |
| 28 frame_(frame), |
| 29 proxy_(proxy), |
| 30 current_time_(0) { |
| 31 } |
| 32 |
| 33 WebMediaPlayerImplAndroid::~WebMediaPlayerImplAndroid() { |
| 34 Destroy(); |
| 35 } |
| 36 |
| 37 void WebMediaPlayerImplAndroid::InitializeMediaPlayer(GURL url) { |
| 38 if (proxy_) |
| 39 proxy_->Initialize(player_id(), url.spec()); |
| 40 |
| 41 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 42 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 43 } |
| 44 |
| 45 void WebMediaPlayerImplAndroid::PlayInternal() { |
| 46 if (paused() && proxy_) |
| 47 proxy_->Start(player_id()); |
| 48 } |
| 49 |
| 50 void WebMediaPlayerImplAndroid::PauseInternal() { |
| 51 if (proxy_) |
| 52 proxy_->Pause(player_id()); |
| 53 } |
| 54 |
| 55 void WebMediaPlayerImplAndroid::SeekInternal(base::TimeDelta time) { |
| 56 if (proxy_) |
| 57 proxy_->Seek(player_id(), time); |
| 58 } |
| 59 |
| 60 float WebMediaPlayerImplAndroid::GetCurrentTimeInternal() const { |
| 61 return current_time_; |
| 62 } |
| 63 |
| 64 void WebMediaPlayerImplAndroid::ReleaseResourcesInternal() { |
| 65 if (proxy_) |
| 66 proxy_->ReleaseResources(player_id()); |
| 67 } |
| 68 |
| 69 void WebMediaPlayerImplAndroid::OnTimeUpdate(base::TimeDelta current_time) { |
| 70 current_time_ = static_cast<float>(current_time.InSecondsF()); |
| 71 } |
| 72 |
| 73 void WebMediaPlayerImplAndroid::Destroy() { |
| 74 proxy_->DestroyPlayer(player_id()); |
| 75 proxy_ = NULL; |
| 76 } |
| 77 |
| 78 } // namespace webkit_media |
| OLD | NEW |