constexpr auto BASE_SCALE = 1.3;
// TODO Temporary feature while support only offline mode
- constexpr auto SCAN_MEDIA_ON_RESUME = true;
+ constexpr auto SCAN_MEDIA_ON_RESUME = false;
}
#endif // __GALLERY_CONFIG_H__
#include "Page.h"
+#include "model/SoundManager.h"
+
namespace gallery {
class VideoPlayerPage final : public Page {
ucl::Result prepare();
+ ucl::Result prepareSoundManager();
+
void createImage();
ucl::Result preparePlayer();
ucl::Result seekToStart();
void showControls();
void hideControls();
+ void showVolumeBtn();
bool updatePlayTimeText();
void updatePlayTimeText(int timeMs);
void setScreenOlwaysOn(bool isAlwaysOn);
+ ucl::Result launchVolumeSettings();
+
+ void onMediaDeviceStateChanged();
+ void onMediaVolumeChanged();
+
void onPlaybackComplete();
void onPlaybackInterrupted(player_interrupted_code_e code);
void onSeekComplete();
Eina_Bool onControlsHideTimer();
Eina_Bool onTickTimer();
- void onVolumeOnBtnClick(ucl::Widget &sender, void *eventInfo);
- void onVolumeMuteBtnClick(ucl::Widget &sender, void *eventInfo);
+ void onVolumeBtnClick(ucl::Widget &sender, void *eventInfo);
void onPlayBtnClick(ucl::Widget &sender, void *eventInfo);
void onPauseBtnClick(ucl::Widget &sender, void *eventInfo);
void onTap(int x, int y);
private:
const MediaItemSRef m_media;
+ SoundManagerSRef m_soundMgr;
ucl::LayoutSRef m_content;
ucl::WidgetSRef m_image;
TouchParserSRef m_touchParser;
inline ucl::Result get(GETTER &&getter, bool optional,
V &result, ARGS &&...args)
{
- V value = {};
+ typename std::remove_pointer<decltype(&result)>::type value = {};
+
const int ret = getter(std::forward<ARGS>(args)..., &value);
if ((ret != 0) || (!optional && !value)) {
UCL_ELOG("get() failed: %d", ret);
setInstancePaused(*m_win, false);
- if (SCAN_MEDIA_ON_RESUME) {
+ if (m_gallery && SCAN_MEDIA_ON_RESUME) {
rescanMediaContent();
}
#include <efl_util.h>
+#include "ucl/appfw/types.h"
+
#include "model/MediaItem.h"
#include "view/TouchParser.h"
Result VideoPlayerPage::prepare()
{
+ FAIL_LOG(prepareSoundManager(), "prepareSoundManager() failed!");
+
m_content = Layout::Builder().
setTheme(impl::LAYOUT_VIDEO_PLAYER).
setIsOwner(true).
return RES_OK;
}
+ Result VideoPlayerPage::prepareSoundManager()
+ {
+ m_soundMgr = SoundManager::newInstance();
+ if (!m_soundMgr) {
+ LOG_RETURN(RES_FAIL, "SoundManager::newInstance() failed!");
+ }
+
+ m_soundMgr->addMediaDeviceStateChangeHandler(WEAK_DELEGATE(
+ VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
+
+ m_soundMgr->addMediaVolumeChangeHandler(WEAK_DELEGATE(
+ VideoPlayerPage::onMediaVolumeChanged, asWeak(*this)));
+
+ return RES_OK;
+ }
+
void VideoPlayerPage::createImage()
{
m_image = makeShared<Widget>(
void VideoPlayerPage::createControls()
{
createButton(impl::STYLE_VOLUME_ON_BTN, impl::PART_VOLUME_ON_BTN,
- WEAK_DELEGATE(VideoPlayerPage::onVolumeOnBtnClick,
+ WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
asWeak(*this)));
createButton(impl::STYLE_VOLUME_MUTE_BTN, impl::PART_VOLUME_MUTE_BTN,
- WEAK_DELEGATE(VideoPlayerPage::onVolumeMuteBtnClick,
+ WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
asWeak(*this)));
createButton(impl::STYLE_PLAY_BTN, impl::PART_PLAY_BTN,
if (!m_isControlsVisible) {
m_isControlsVisible = true;
+ if (m_soundMgr && m_soundMgr->isMediaDeviceReady()) {
+ showVolumeBtn();
+ }
+
if (m_state == State::PLAYING) {
m_content->emit(impl::SHOW_PAUSE_BTN);
resetTickTimer();
}
}
+ void VideoPlayerPage::showVolumeBtn()
+ {
+ if (m_soundMgr->getCurrentMediaVolume() > 0) {
+ m_content->emit(impl::SHOW_VOLUME_ON_BTN);
+ } else {
+ m_content->emit(impl::SHOW_VOLUME_MUTE_BTN);
+ }
+ }
+
bool VideoPlayerPage::updatePlayTimeText()
{
int playPosition = 0;
EFL_UTIL_SCREEN_MODE_DEFAULT));
}
+ Result VideoPlayerPage::launchVolumeSettings()
+ {
+ AutoAppCtrl appCtrl;
+
+ FAIL_RETURN(util::getNz(app_control_create, appCtrl),
+ "app_control_create() failed!");
+
+ FAIL_RETURN(util::call(app_control_set_app_id,
+ appCtrl, "org.tizen.watch-setting"),
+ "app_control_set_app_id() failed!");
+
+ FAIL_RETURN(util::call(app_control_add_extra_data,
+ appCtrl, "launch-type", "volume"),
+ "app_control_add_extra_data() failed!");
+
+ FAIL_RETURN(util::call(app_control_send_launch_request,
+ appCtrl, nullptr, nullptr),
+ "app_control_send_launch_request() failed!");
+
+ return RES_OK;
+ }
+
+ void VideoPlayerPage::onMediaDeviceStateChanged()
+ {
+ if (m_isControlsVisible) {
+ if (m_soundMgr->isMediaDeviceReady()) {
+ showVolumeBtn();
+ } else {
+ m_content->emit(impl::HIDE_VOLUME_BTN);
+ }
+ }
+ }
+
+ void VideoPlayerPage::onMediaVolumeChanged()
+ {
+ if (m_isControlsVisible) {
+ if (m_soundMgr->isMediaDeviceReady()) {
+ showVolumeBtn();
+ }
+ }
+ }
+
void VideoPlayerPage::onPlaybackComplete()
{
m_isPlaybackCompleted = true;
return ECORE_CALLBACK_RENEW;
}
- void VideoPlayerPage::onVolumeOnBtnClick(Widget &sender, void *eventInfo)
- {
- }
-
- void VideoPlayerPage::onVolumeMuteBtnClick(Widget &sender, void *eventInfo)
+ void VideoPlayerPage::onVolumeBtnClick(Widget &sender, void *eventInfo)
{
+ FAIL_LOG(launchVolumeSettings(), "launchVolumeSettings() failed!");
}
void VideoPlayerPage::onPlayBtnClick(Widget &sender, void *eventInfo)
</ui-application>\r
<privileges>\r
<privilege>http://tizen.org/privilege/mediastorage</privilege>\r
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
<privilege>http://tizen.org/privilege/externalstorage</privilege>\r
<privilege>http://tizen.org/privilege/content.write</privilege>\r
</privileges>\r
#include "ucl/misc/HashMap.h"
#include "ucl/misc/Event.h"
+#include "ucl/misc/AutoHandle.h"
namespace ucl {
};
using SysEventHandler = Delegate<void(SysEvent)>;
+
+ using AutoAppCtrl = AutoHandle<app_control_h, int, app_control_destroy>;
}
#endif // __UCL_APPFW_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __UCL_MISC_AUTO_HANDLE_H__
+#define __UCL_MISC_AUTO_HANDLE_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+ template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+ struct AutoHandle final : ucl::NonCopyable {
+ using Handle = HANDLE;
+
+ HANDLE value;
+
+ AutoHandle() :
+ value()
+ {
+ }
+
+ AutoHandle(std::nullptr_t) :
+ AutoHandle()
+ {
+ }
+
+ AutoHandle(HANDLE value) :
+ value(value)
+ {
+ }
+
+ ~AutoHandle()
+ {
+ if (value) {
+ DEL_FUNC(value);
+ }
+ }
+
+ AutoHandle(AutoHandle &&src) :
+ value(src.value)
+ {
+ src.value = nullptr;
+ }
+
+ AutoHandle &operator=(AutoHandle src)
+ {
+ swap(*this, src);
+ return *this;
+ }
+
+ AutoHandle &operator=(HANDLE value)
+ {
+ AutoHandle src{value};
+ swap(*this, src);
+ return *this;
+ }
+
+ HANDLE *operator&()
+ {
+ return &value;
+ }
+
+ operator HANDLE()
+ {
+ return value;
+ }
+ };
+
+ // Non-member functions //
+
+ template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+ inline void swap(AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &x,
+ AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &y) noexcept
+ {
+ std::swap(x.value, y.value);
+ }
+}
+
+#endif // __UCL_MISC_AUTO_HANDLE_H__