public void Display(SoundDataObject dataObject, string time)
        {
            try
            {
                DataObject  = dataObject;
                TimeComment = time;

                CommentWindow = new Dialog(ActivityContext, Resource.Style.Theme_D1NoTitleDim);

                if (AppSettings.EnableBlurBackgroundComment)
                {
                    Resources res = Application.Context.Resources;

                    CommentWindow.Create();
                    Bitmap   map  = TakeScreenShot(GlobalContext);
                    Bitmap   fast = FastBlur(map);
                    Drawable draw = new BitmapDrawable(res, fast);
                    CommentWindow.Window.SetBackgroundDrawable(draw);
                }

                CommentWindow.SetContentView(Resource.Layout.CommentsLayout);

                InitComponent();
                SetRecyclerViewAdapters();

                StartApiService();

                CommentWindow.Show();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public void StartDownloadManager(string title, SoundDataObject sound, string fromActivity)
        {
            try
            {
                if (sound != null && !string.IsNullOrEmpty(title))
                {
                    FromActivity = fromActivity;
                    Console.WriteLine(FromActivity);

                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.InsertOrUpdate_LatestDownloadsSound(sound);
                    sqlEntity.Dispose();

                    Request.SetTitle(title);
                    Request.SetAllowedNetworkTypes(DownloadNetwork.Wifi | DownloadNetwork.Mobile);
                    Request.SetDestinationInExternalPublicDir("/" + AppSettings.ApplicationName + "/Sound/", Filename);
                    Request.SetNotificationVisibility(DownloadVisibility.Visible);
                    Request.SetAllowedOverRoaming(true);
                    DownloadId = DownloadManager.Enqueue(Request);

                    OnDownloadComplete onDownloadComplete = new OnDownloadComplete();
                    onDownloadComplete.SetData(ActivityContext, fromActivity, sound);
                    Application.Context.ApplicationContext.RegisterReceiver(onDownloadComplete, new IntentFilter(DownloadManager.ActionDownloadComplete));
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_Download_failed), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        private void SetPlayAudio()
        {
            try
            {
                if (Constant.MediaPlayer == null)
                {
                    return;
                }

                try
                {
                    if (Constant.MediaPlayer.IsPlaying)
                    {
                        Constant.MediaPlayer.Stop();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                IsReset = true;
                Constant.MediaPlayer.Reset();

                Item = Constant.ArrayListPlay[Constant.PlayPos];
                if (Item == null)
                {
                    return;
                }

                ChangeText();
                Uri mediaUri;

                if (Item.Price == 0 || Item.IsOwner || Item.IsPurchased)
                {
                    mediaUri = Uri.Parse(Item.AudioLocation);
                }
                else if (!string.IsNullOrEmpty(Item.DemoTrack))
                {
                    if (!Item.DemoTrack.Contains(Client.WebsiteUrl))
                    {
                        Item.DemoTrack = Client.WebsiteUrl + "/" + Item.DemoTrack;
                    }

                    mediaUri = Uri.Parse(Item.DemoTrack);
                }
                else
                {
                    mediaUri = Uri.Parse(Item.AudioLocation);
                }

                Constant.MediaPlayer.SetDataSource(Constant.Context, mediaUri);
                Constant.MediaPlayer.PrepareAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void SetData()
        {
            try
            {
                Console.WriteLine(NamePage);
                SongsClass = JsonConvert.DeserializeObject <SoundDataObject>(Intent.GetStringExtra("ItemDataSong"));
                if (SongsClass != null)
                {
                    PathImage = "";

                    GlideImageLoader.LoadImage(this, SongsClass.Thumbnail, PlaylistImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                    TxtSubTitle.Text = GetText(Resource.String.Lbl_subTitleUploadSong) + " " + SongsClass.AudioLocation.Split('/').Last();

                    TitleEditText.Text       = SongsClass.Title;
                    DescriptionEditText.Text = Methods.FunString.DecodeString(SongsClass.Description);
                    LyricsEditText.Text      = Methods.FunString.DecodeString(SongsClass.Lyrics);
                    TagsEditText.Text        = SongsClass.Tags;
                    GenresEditText.Text      = Methods.FunString.DecodeString(SongsClass.CategoryName);

                    if (SongsClass.Price == 0)
                    {
                        PriceEditText.Text = GetText(Resource.String.Lbl_Free);
                    }
                    else
                    {
                        PriceEditText.Text = CurrencySymbol + SongsClass.Price;
                    }

                    AgeRestrictionEditText.Text = GetString(SongsClass.AgeRestriction == 0 ? Resource.String.Lbl_AgeRestrictionText0 : Resource.String.Lbl_AgeRestrictionText1);
                    AllowDownloadsEditText.Text = GetString(SongsClass.AllowDownloads == 0 ? Resource.String.Lbl_No : Resource.String.Lbl_Yes);

                    if (SongsClass.Availability == 0)
                    {
                        RbPublic.Checked  = true;
                        RbPrivate.Checked = false;
                    }
                    else
                    {
                        RbPublic.Checked  = false;
                        RbPrivate.Checked = true;
                    }

                    Status           = SongsClass.Availability.ToString();
                    IdGenres         = SongsClass.CategoryId.ToString();
                    IdPrice          = SongsClass.Price.ToString();
                    IdAgeRestriction = SongsClass.AgeRestriction.ToString();
                    IdAllowDownloads = SongsClass.AllowDownloads.ToString();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 5
0
        private async void OnPrepared()
        {
            try
            {
                Constant.IsPlayed             = true;
                Constant.Player.PlayWhenReady = true;

                bool haveResumePosition = ResumeWindow != C.IndexUnset;
                if (haveResumePosition)
                {
                    Constant.Player.SeekTo(ResumeWindow, ResumePosition);
                }

                IsReset = false;

                SetBuffer(false);

                CreateNoti();

                UpdateNoti();

                if (Item != null)
                {
                    //add to Recent Played
                    if (UserDetails.IsLogin)
                    {
                        GlobalContext?.LibrarySynchronizer.AddToRecentlyPlayed(Item);
                    }

                    (int apiStatus, var respond) = await RequestsAsync.Tracks.GetTrackInfoAsync(Item.Id.ToString()).ConfigureAwait(false);

                    if (apiStatus.Equals(200))
                    {
                        if (respond is GetTrackInfoObject result)
                        {
                            var data = Constant.ArrayListPlay.FirstOrDefault(a => a.Id == Item.Id);
                            if (data != null)
                            {
                                data = result.Data;
                                Item = result.Data;
                            }

                            Console.WriteLine(data);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 6
0
        private void OnCompletion()
        {
            try
            {
                if (IsReset)
                {
                    return;
                }

                Item = Constant.ArrayListPlay[Constant.PlayPos];

                if (Item.IsPurchased != null && Item.IsOwner != null && Item != null && Item.Price != 0 && !Item.IsOwner.Value && !Item.IsPurchased.Value)
                {
                    //This song is paid, You must pay
                    if (!string.IsNullOrEmpty(Item.DemoTrack))
                    {
                        GlobalContext?.OpenDialogPurchaseSound(Item);
                    }
                }
                else
                {
                    if (Constant.IsRepeat)
                    {
                        Constant.Player.SeekTo(ResumeWindow, 0);
                        Constant.Player.PlayWhenReady = true;
                    }
                    else
                    {
                        if (Constant.IsSuffle)
                        {
                            Random rand = new Random();
                            Constant.PlayPos = rand.Next((Constant.ArrayListPlay.Count - 1) + 1);
                            SetPlayAudio();
                        }
                        else
                        {
                            SetNext();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 7
0
        //Insert Or Update Latest Downloads Sound
        public void InsertOrUpdate_LatestDownloadsSound(SoundDataObject info)
        {
            try
            {
                using (OpenConnection())
                {
                    if (Connection == null)
                    {
                        return;
                    }

                    if (info != null)
                    {
                        var select = Connection.Table <DataTables.LatestDownloadsTb>().FirstOrDefault(a => a.Id == info.Id);
                        if (select != null)
                        {
                            var db = Mapper.Map <DataTables.LatestDownloadsTb>(info);
                            db.Publisher    = JsonConvert.SerializeObject(info.Publisher);
                            db.TagsArray    = JsonConvert.SerializeObject(info.TagsArray);
                            db.TagsFiltered = JsonConvert.SerializeObject(info.TagsFiltered);
                            db.SongArray    = JsonConvert.SerializeObject(info.SongArray);
                            db.Comments     = JsonConvert.SerializeObject(info.Comments);
                            Connection.Update(db);
                        }
                        else
                        {
                            var db = Mapper.Map <DataTables.LatestDownloadsTb>(info);
                            db.Publisher    = JsonConvert.SerializeObject(info.Publisher);
                            db.TagsArray    = JsonConvert.SerializeObject(info.TagsArray);
                            db.TagsFiltered = JsonConvert.SerializeObject(info.TagsFiltered);
                            db.SongArray    = JsonConvert.SerializeObject(info.SongArray);
                            db.Comments     = JsonConvert.SerializeObject(info.Comments);
                            Connection.Insert(db);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        public void Display(SoundDataObject dataObject)
        {
            try
            {
                DataObject = dataObject;

                InfoSongWindow = new Dialog(ActivityContext, AppSettings.SetTabDarkTheme ? Resource.Style.MyDialogThemeDark : Resource.Style.MyDialogTheme);
                InfoSongWindow.SetContentView(Resource.Layout.DialogInfoSongLayout);

                InitComponent();
                AddOrRemoveEvent(true);
                SetDataSong();

                InfoSongWindow.Show();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 9
0
        public void AddToLatestDownloads(SoundDataObject song, int count = 0)
        {
            try
            {
                var item = ActivityContext?.LibraryFragment?.MAdapter?.LibraryList?.FirstOrDefault(a => a.SectionId == "4");
                if (item == null)
                {
                    return;
                }
                item.SongsCount      = count != 0 ? count : item.SongsCount + 1;
                item.BackgroundImage = song.Thumbnail;
                ActivityContext?.LibraryFragment?.MAdapter?.NotifyItemChanged(3, "picture");

                var sqlEntity = new SqLiteDatabase();
                sqlEntity.InsertLibraryItem(item);
                sqlEntity.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 10
0
        public void OnClick(MaterialDialog p0, DialogAction p1)
        {
            try
            {
                if (TypeDialog == "DeleteSong")
                {
                    if (p1 == DialogAction.Positive)
                    {
                        MainContext.RunOnUiThread(() =>
                        {
                            try
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    SoundDataObject dataSong = null;
                                    dynamic mAdapter         = null;

                                    switch (NamePage)
                                    {
                                    //Delete Song from list
                                    case "FavoritesFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.FavoritesFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.FavoritesFragment?.MAdapter;
                                        break;

                                    case "LatestDownloadsFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.LatestDownloadsFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.LatestDownloadsFragment?.MAdapter;
                                        break;

                                    case "LikedFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.LikedFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.LikedFragment?.MAdapter;
                                        break;

                                    case "RecentlyPlayedFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.RecentlyPlayedFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.RecentlyPlayedFragment?.MAdapter;
                                        break;

                                    case "SharedFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.SharedFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.SharedFragment?.MAdapter;
                                        break;

                                    case "PurchasesFragment":
                                        dataSong = GlobalContext?.LibraryFragment?.PurchasesFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.LibraryFragment?.PurchasesFragment?.MAdapter;
                                        break;

                                    case "SongsByGenresFragment":
                                        dataSong = GlobalContext?.MainFragment?.SongsByGenresFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.MainFragment?.SongsByGenresFragment?.MAdapter;
                                        break;

                                    case "SongsByTypeFragment":
                                        dataSong = GlobalContext?.MainFragment?.SongsByTypeFragment?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.MainFragment?.SongsByTypeFragment?.MAdapter;
                                        break;

                                    case "SearchSongsFragment":
                                        dataSong = GlobalContext?.BrowseFragment?.SearchFragment?.SongsTab?.MAdapter?.SoundsList?.FirstOrDefault(a => a.Id == MoreSongArgs.SongsClass.Id);
                                        mAdapter = GlobalContext?.BrowseFragment?.SearchFragment?.SongsTab?.MAdapter;
                                        break;
                                    }

                                    if (mAdapter != null)
                                    {
                                        if (dataSong is SoundDataObject data)
                                        {
                                            mAdapter.SoundsList.Remove(data);

                                            int index = mAdapter.SoundsList.IndexOf(data);
                                            if (index >= 0)
                                            {
                                                mAdapter.NotifyItemRemoved(index);
                                            }
                                        }
                                    }

                                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_SongSuccessfullyDeleted), ToastLength.Short).Show();

                                    //Sent Api >>
                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Tracks.DeleteTrackAsync(MoreSongArgs.SongsClass.Id.ToString())
                                    });
                                }
                                else
                                {
                                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                    else if (p1 == DialogAction.Negative)
                    {
                        p0.Dismiss();
                    }
                }
                else
                {
                    if (p1 == DialogAction.Positive)
                    {
                    }
                    else if (p1 == DialogAction.Negative)
                    {
                        p0.Dismiss();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
            public override void OnReceive(Context context, Intent intent)
            {
                try
                {
                    if (intent.Action == DownloadManager.ActionDownloadComplete)
                    {
                        if (ActivityContext == null)
                        {
                            return;
                        }

                        DownloadManager       downloadManagerExcuter = (DownloadManager)Application.Context.GetSystemService(Context.DownloadService);
                        long                  downloadId             = intent.GetLongExtra(DownloadManager.ExtraDownloadId, -1);
                        DownloadManager.Query query = new DownloadManager.Query();
                        query.SetFilterById(downloadId);
                        ICursor c         = downloadManagerExcuter.InvokeQuery(query);
                        var     sqlEntity = new SqLiteDatabase();

                        if (c.MoveToFirst())
                        {
                            int columnIndex = c.GetColumnIndex(DownloadManager.ColumnStatus);
                            if (c.GetInt(columnIndex) == (int)DownloadStatus.Successful)
                            {
                                string downloadedPath = c.GetString(c.GetColumnIndex(DownloadManager.ColumnLocalUri));

                                ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
                                ActivityManager.GetMyMemoryState(appProcessInfo);
                                if (appProcessInfo.Importance == Importance.Foreground || appProcessInfo.Importance == Importance.Background)
                                {
                                    sqlEntity.InsertOrUpdate_LatestDownloadsSound(Sound, downloadedPath);
                                    if (TypeActivity == "Main")
                                    {
                                        if (ActivityContext is HomeActivity tabbedMain)
                                        {
                                            tabbedMain.SoundController.BtnIconDownload.Tag = "Downloaded";
                                            tabbedMain.SoundController.BtnIconDownload.SetImageResource(Resource.Drawable.ic_check_circle);
                                            tabbedMain.SoundController.BtnIconDownload.SetColorFilter(Color.Red);

                                            tabbedMain.SoundController.ProgressBarDownload.Visibility = ViewStates.Invisible;
                                            tabbedMain.SoundController.BtnIconDownload.Visibility     = ViewStates.Visible;

                                            tabbedMain.LibrarySynchronizer.AddToLatestDownloads(Sound);
                                        }
                                    }
                                }
                                else
                                {
                                    //sqlEntity.InsertOrUpdate_LatestDownloadsSound(Sound.Id, downloadedPath);
                                }
                            }
                        }

                        sqlEntity.Dispose();
                        Sound           = null;
                        ActivityContext = null;
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
 public void SetData(Context activityContext, string fromActivity, SoundDataObject sound)
 {
     ActivityContext = activityContext;
     TypeActivity    = fromActivity;
     Sound           = sound;
 }
Esempio n. 13
0
        private void SetPlayAudio()
        {
            try
            {
                if (Constant.Player == null)
                {
                    return;
                }

                try
                {
                    if (Constant.Player.PlayWhenReady)
                    {
                        Constant.Player.Stop();
                        Constant.Player.Release();
                    }

                    Constant.Player = null;
                    InitializePlayer();

                    //GC Collector
                    GC.Collect();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                IsReset = true;

                Item = Constant.ArrayListPlay[Constant.PlayPos];
                if (Item == null)
                {
                    return;
                }

                ChangeText();
                Uri mediaUri;

                if (Item.AudioLocation.Contains("stream") && Item.AudioLocationOriginal.Contains("stream"))
                {
                    mediaUri = Uri.Parse(Item.AudioLocationOriginal);
                }
                else if (!string.IsNullOrEmpty(Item.AudioLocation) && Item.AudioLocation.Contains("http"))
                {
                    if (Item.IsPurchased != null && Item.IsOwner != null && (Item.Price == 0 || Item.IsOwner.Value || Item.IsPurchased.Value))
                    {
                        mediaUri = Uri.Parse(Item.AudioLocation);
                    }
                    else if (Item.Price != 0 && !string.IsNullOrEmpty(Item.DemoTrack))
                    {
                        if (!Item.DemoTrack.Contains(Client.WebsiteUrl))
                        {
                            Item.DemoTrack = Client.WebsiteUrl + "/" + Item.DemoTrack;
                        }

                        mediaUri = Uri.Parse(Item.DemoTrack);
                    }
                    else
                    {
                        mediaUri = Uri.Parse(Item.AudioLocation);
                    }
                }
                else if (!string.IsNullOrEmpty(Item.AudioLocation) && (Item.AudioLocation.Contains("file://") || Item.AudioLocation.Contains("content://") || Item.AudioLocation.Contains("storage") || Item.AudioLocation.Contains("/data/user/0/")))
                {
                    mediaUri = Uri.Parse(Item.AudioLocation);
                }
                else
                {
                    mediaUri = Uri.Parse(Item.AudioLocation);
                }

                PlayerSource = null;
                PlayerSource = GetMediaSourceFromUrl(mediaUri, "normal");
                Constant.Player?.Prepare(PlayerSource);
                Constant.Player?.AddListener(PlayerListener);

                OnPrepared();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public PopupDialogController(Activity activity, SoundDataObject soundData, string typeDialog)
 {
     ActivityContext = activity;
     SoundData       = soundData;
     TypeDialog      = typeDialog;
 }