blob: b23a1b952f3d7d5058e2e41c51974ba9cb862b22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/values.h"
#include "chrome/browser/chromeos/media/media_player.h"
#include "chrome/browser/chromeos/media/media_player_extension_api.h"
static const char kPropertyItems[] = "items";
static const char kPropertyPosition[] = "position";
bool PlayMediaplayerFunction::RunImpl() {
if (args_->GetSize() < 2) {
return false;
}
ListValue* url_list = NULL;
if (!args_->GetList(0, &url_list))
return false;
int position;
if (!args_->GetInteger(1, &position))
return false;
MediaPlayer* player = MediaPlayer::GetInstance();
player->PopupMediaPlayer();
player->ClearPlaylist();
size_t len = url_list->GetSize();
for (size_t i = 0; i < len; ++i) {
std::string path;
url_list->GetString(i, &path);
player->EnqueueMediaFileUrl(GURL(path));
}
player->SetPlaylistPosition(position);
player->NotifyPlaylistChanged();
return true;
}
static ListValue* GetPlaylistItems() {
ListValue* result = new ListValue();
MediaPlayer::UrlVector const& src = MediaPlayer::GetInstance()->GetPlaylist();
for (size_t i = 0; i < src.size(); i++) {
result->Append(Value::CreateStringValue(src[i].spec()));
}
return result;
}
bool GetPlaylistMediaplayerFunction::RunImpl() {
DictionaryValue* result = new DictionaryValue();
MediaPlayer* player = MediaPlayer::GetInstance();
result->Set(kPropertyItems, GetPlaylistItems());
result->SetInteger(kPropertyPosition, player->GetPlaylistPosition());
result_.reset(result);
return true;
}
bool SetWindowHeightMediaplayerFunction::RunImpl() {
int height;
if (!args_->GetInteger(0, &height))
return false;
MediaPlayer::GetInstance()->SetWindowHeight(height);
return true;
}
bool CloseWindowMediaplayerFunction::RunImpl() {
MediaPlayer::GetInstance()->CloseWindow();
return true;
}
|