--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+
+namespace MusicPlayer.Common
+{
+ public static class NUISynchronizationContext
+ {
+ private static SynchronizationContext context;
+
+ public static void Initialize()
+ {
+ context = SynchronizationContext.Current;
+ }
+
+ public static void InvokeOnNUIThread(SendOrPostCallback callback, object arg)
+ {
+ context?.Post(callback, arg);
+ }
+ }
+}
private static Palette GeneratePalette(string imagePath)
{
- PixelBuffer pixelBuffer = ImageLoading.LoadImageFromFile(imagePath);
+ PixelBuffer pixelBuffer = ImageLoader.LoadImageFromFile(imagePath);
if(pixelBuffer == null)
{
Tizen.Log.Error(AppConstants.LogTag, "Pixel buffer is null");
{
Tizen.Log.Error("MusicPlayer", "InvalidOperationException: "+ex.Message);
}
- finally // TODO do we really need this
+ catch(Exception ex)
{
- //DisposePlayer();
+ Tizen.Log.Error(AppConstants.LogTag, "Exception : " + ex.Message);
+ EmitErrorEvent(ex.Message);
}
}
Tizen.Log.Error(AppConstants.LogTag, "Playback completed");
}
- // TODO this event is called on a differnt thread..need to handle it
+ private void EmitErrorEvent(object o)
+ {
+ string error = (string)o;
+ PlayerEvent.Invoke(this, new PlayerEventArgs(EventType.Error, error));
+ }
+
private void OnErrorOccurred(object sender, PlayerErrorOccurredEventArgs e)
{
- PlayerEvent.Invoke(this, new PlayerEventArgs(EventType.Error, e.Error.ToString()));
- Tizen.Log.Error(AppConstants.LogTag, "Error Occurred: " + e.Error.ToString());
+ Tizen.Log.Debug(AppConstants.LogTag, "ThreadId: " + System.Threading.Thread.CurrentThread.ManagedThreadId+ "Error Occured: "+e.Error.ToString());
+ System.Threading.SendOrPostCallback errorEventCallback = new System.Threading.SendOrPostCallback(EmitErrorEvent);
+ NUISynchronizationContext.InvokeOnNUIThread(errorEventCallback, GetErrorDescription(e.Error));
+ }
+
+ private string GetErrorDescription(PlayerError error)
+ {
+ string errorDesc = "Unknown error encountered";
+ switch (error)
+ {
+ case PlayerError.NoSuchFile:
+ errorDesc = "File doesn't exists or invalid file";
+ break;
+ case PlayerError.InternalError:
+ errorDesc = "Player internal error encountered";
+ break;
+ case PlayerError.NoSpaceOnDevice:
+ errorDesc = "Not enough space on device";
+ break;
+ case PlayerError.NotSupportedFile:
+ errorDesc = "File type not supported";
+ break;
+ case PlayerError.InvalidUri:
+ errorDesc = "File path is not valid";
+ break;
+ case PlayerError.AudioCodecNotSupported:
+ errorDesc = "Audio codec not supported";
+ break;
+ }
+ return errorDesc;
}
}
}
{
Tizen.Log.Info(AppConstants.LogTag, "OnCreate statrted");
base.OnCreate();
+
+ //Initlize NUISynchronizationContext
+ NUISynchronizationContext.Initialize();
+
Window window = Window.Instance;
window.BackgroundColor = Color.White;
Size2D size = window.Size;
{
PlayNext();
}
+ else if(e.Type == EventType.Error)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "ThreadId: " + System.Threading.Thread.CurrentThread.ManagedThreadId + ", Error Occured: " + e.Description);
+ }
}
private void PlayNext()
FlexLayout.SetFlexGrow(contentView, 1);
FlexLayout.SetFlexShrink(contentView, 1);
- tabs = new Tab()
+ tabs = new Tab("Tabs")
{
ThemeChangeSensitive = true,
Size2D = new Size2D(Window.Instance.Size.Width, 84),
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = 84,
- UnderLineBackgroundColor = Color.Blue,
- UnderLineSize = new Size2D(1, 3),
- PointSize = 25,
- BackgroundColor = Color.White,
- };
- tabs.TextColorSelector = new ColorSelector
- {
- Normal = Color.Black,
- Selected = Color.Magenta,
};
base.Add(tabs);
for(int i = 0; i<4; ++i)
</c:ButtonStyle.Icon>
</c:ButtonStyle>
+ <c:TabStyle x:Key="Tabs" BackgroundColor="#000209">
+ <c:TabStyle.Text>
+ <TextLabelStyle TextColor="#FFFFFF" FontFamily="BreezeSans" PixelSize="28"/>
+ </c:TabStyle.Text>
+ <c:TabStyle.UnderLine>
+ <ViewStyle BackgroundColor="#FFFFFF" SizeHeight="8"/>
+ </c:TabStyle.UnderLine>
+ </c:TabStyle>
+
</Theme>
\ No newline at end of file
</c:ButtonStyle.Icon>
</c:ButtonStyle>
+ <c:TabStyle x:Key="Tabs" BackgroundColor="White">
+ <c:TabStyle.Text>
+ <TextLabelStyle TextColor="#000C2B" FontFamily="BreezeSans" PixelSize="28"/>
+ </c:TabStyle.Text>
+ <c:TabStyle.UnderLine>
+ <ViewStyle BackgroundColor="#0A0E4A" SizeHeight="8"/>
+ </c:TabStyle.UnderLine>
+ </c:TabStyle>
+
</Theme>
\ No newline at end of file