-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable MediaPlaybackService by default.
Use H5vcc.settings.set(Media.BackgroundPlaybackEnabled, 1) to enable it. b/319146388
- Loading branch information
Colin Liang
committed
Jan 10, 2024
1 parent
aef8f7b
commit f6616e3
Showing
10 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
cobalt/demos/content/enable-background-playback/enable-background-playback-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
|
||
<head> | ||
<title>Test Enable Background Playback</title> | ||
</head> | ||
|
||
<body style="color: white;"> | ||
<script> | ||
function main() { | ||
if (window.h5vcc && window.h5vcc.settings) { | ||
h5vcc.settings.set('Media.BackgroundPlaybackEnabled', 1); | ||
} | ||
} | ||
main(); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "starboard/extension/h5vcc_config.h" | ||
#include "starboard/android/shared/h5vcc_config.h" | ||
#include "starboard/android/shared/jni_env_ext.h" | ||
#include "starboard/android/shared/jni_utils.h" | ||
#include "starboard/common/log.h" | ||
|
||
namespace starboard { | ||
namespace android { | ||
namespace shared { | ||
|
||
namespace { | ||
|
||
// Definitions of any functions included as components in the extension | ||
// are added here. | ||
|
||
void EnableBackgroundPlayback(bool value) { | ||
JniEnvExt* env = JniEnvExt::Get(); | ||
JniEnvExt::Get()->CallStarboardVoidMethodOrAbort("enableBackgroundPlayback", | ||
"(Z)V", (jboolean)value); | ||
} | ||
|
||
const StarboardExtensionH5vccConfigApi kH5vccConfigApi = { | ||
kStarboardExtensionH5vccConfigName, | ||
1, // API version that's implemented. | ||
&EnableBackgroundPlayback, | ||
}; | ||
|
||
} // namespace | ||
|
||
const void* GetH5vccConfigApi() { | ||
return &kH5vccConfigApi; | ||
} | ||
|
||
} // namespace shared | ||
} // namespace android | ||
} // namespace starboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef STARBOARD_ANDROID_SHARED_H5VCC_CONFIG_H_ | ||
#define STARBOARD_ANDROID_SHARED_H5VCC_CONFIG_H_ | ||
|
||
// Omit namespace linux due to symbol name conflict. | ||
namespace starboard { | ||
namespace android { | ||
namespace shared { | ||
|
||
const void* GetH5vccConfigApi(); | ||
|
||
} // namespace shared | ||
} // namespace android | ||
} // namespace starboard | ||
|
||
#endif // STARBOARD_ANDROID_SHARED_H5VCC_CONFIG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef STARBOARD_EXTENSION_H5VCC_CONFIG_H_ | ||
#define STARBOARD_EXTENSION_H5VCC_CONFIG_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define kStarboardExtensionH5vccConfigName "dev.starboard.extension.H5vccConfig" | ||
|
||
typedef struct StarboardExtensionH5vccConfigApi { | ||
// Name should be the string |kStarboardExtensionH5vccConfigName|. | ||
// This helps to validate that the extension API is correct. | ||
const char* name; | ||
|
||
// This specifies the version of the API that is implemented. | ||
uint32_t version; | ||
|
||
// This API enable the Cobalt background playback mode on Android TV. | ||
void (*EnableBackgroundPlayback)(bool value); | ||
|
||
} StarboardExtensionH5vccConfigApi; | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // STARBOARD_EXTENSION_H5VCC_CONFIG_H_ |