2
* Copyright (C) 2007 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
#include "StringHash.h"
33
#include <wtf/HashSet.h>
34
#include <wtf/Noncopyable.h>
39
class GraphicsContext;
42
class MediaPlayerPrivate;
45
class MediaPlayerClient {
47
virtual ~MediaPlayerClient() { }
48
virtual void mediaPlayerNetworkStateChanged(MediaPlayer*) { }
49
virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { }
50
virtual void mediaPlayerVolumeChanged(MediaPlayer*) { }
51
virtual void mediaPlayerTimeChanged(MediaPlayer*) { }
52
virtual void mediaPlayerRepaint(MediaPlayer*) { }
55
class MediaPlayer : Noncopyable {
57
MediaPlayer(MediaPlayerClient*);
58
virtual ~MediaPlayer();
60
static bool isAvailable();
61
static void getSupportedTypes(HashSet<String>&);
63
IntSize naturalSize();
66
void setFrameView(FrameView* frameView) { m_frameView = frameView; }
68
IntRect rect() const { return m_rect; }
69
void setRect(const IntRect& r);
71
void load(const String& url);
75
void setVisible(bool);
83
float duration() const;
84
float currentTime() const;
85
void seek(float time);
87
void setEndTime(float time);
92
float maxTimeBuffered();
93
float maxTimeSeekable();
95
unsigned bytesLoaded();
96
bool totalBytesKnown();
97
unsigned totalBytes();
100
void setVolume(float);
102
int dataRate() const;
104
void paint(GraphicsContext*, const IntRect&);
106
enum NetworkState { Empty, LoadFailed, Loading, LoadedMetaData, LoadedFirstFrame, Loaded };
107
NetworkState networkState();
109
enum ReadyState { DataUnavailable, CanShowCurrentFrame, CanPlay, CanPlayThrough };
110
ReadyState readyState();
112
void networkStateChanged();
113
void readyStateChanged();
114
void volumeChanged();
121
friend class MediaPlayerPrivate;
123
MediaPlayerClient* m_mediaPlayerClient;
124
MediaPlayerPrivate* m_private;
125
FrameView* m_frameView;