tutorials
How to Make a Video Player for Tizen Wearables
Juwon Ahn
Staff Engineer
You can play media files stored in Galaxy Watch, or present over the Internet in your application. In this post, we discuss how to create a video player for Tizen wearables.
An Introduction to Circular UI MediaView and MediaPlayer APIs
Tizen.Multimedia API in TizenFX API is available to make certain apps, such as video players. We recommend using this API for detailed control of media content.
As of Tizen.CircularUI version 1.1.0, MediaView and MediaPlayer APIs are provided in the Tizen.CircularUI API to make it easier to use. The following documents provide further information on how to use:
-
API specifications
-- Tizen.Wearable.CircularUI.Forms.MediaView
-
Developer guide
Necessary privileges
The screen must remain on while playing video content.
Internet connectivity is required. Your app must be allowed to access the Internet to use online content.
In the tizen-manifest.xml
file:
-
To access the Internet, declare
http://tizen.org/privilege/internet
. -
To keep the screen on while playing a video, declare
http://tizen.org/privilege/display
.
The http://tizen.org/privilege/internet
privilege is a privacy-related privileges. A user's permission must be granted.
User permission for privacy privileges
An app user's permission must granted to use privacy-related functionality. For more information about how your app can be granted permission to allow use of privacy-related features, see Galaxy Watch: working with user privacy related permissions in Tizen .NET Applications
In addition, check the list of the privacy-related privileged APIs.
Keep the screen on during video play
Video apps need to have the screen on while playing. To do this, use Power class APIs, which allow your application to control the screen state of the watch device.
These APIs have a significant effect on a Galaxy watch's battery life. We recommend you use them only when really necessary and hold the display lock for as short a time as possible.
Power.RequestLock() and Power.ReleaseLock() have been provided since Tizen 5.0 and therefore are unavailable for use on Tizen 4.0-based Galaxy watches. As an alternative, use Tizen Native Power API using DllImport.
Use DllImport to call native APIs
The following code shows how to use Tizen native Power APIs in Tizen .NET apps.
using System.Runtime.InteropServices;
enum Power_Type {CPU = 0, DISPLAY, DISPLAY_DIM};
void MakeScreenOn()
{
DevicePowerRequestLock(DISPLAY, 0);
}
void MakeScreenOff()
{
DevicePowerReleaseLock(DISPLAY);
}
[DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_request_lock", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DevicePowerRequestLock(int type, int timeout_ms);
[DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_release_lock", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DevicePowerReleaseLock(int type);
For devices based on Tizen 5.0 and above, use Tizen .NET Power API instead of DllImport.
Simple Video Player App
You can download simple sample code and get info about how to test this app.
Playing videos on your watch! What else can you do with Tizen .NET on your Galaxy wearable apps? Download these samples, try them out, and let your imagination roam.