陈嘉乐
2020-07-31 52e317b95d830f8cd1156b403ff5a34fb8f9bccb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using Shared;
using HDL_ON.UI.Music;
namespace HDL_ON.UI.UI2.FuntionControlView.Music
{
    public class UpdateThread
    {
        public UpdateThread()
        {
        }
        /// <summary>
        /// 定时更新当前播放音乐
        /// </summary>
        /// <param name="frame">当前界面</param>
        /// <param name="middViewLayout">每一条音乐的主控件</param>
        /// <param name="a31MusicModel">点前播放器</param>
        public static void updateThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel)
        {
            System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() =>
            {
                while (frame.Parent != null)
                {
                    A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程");
                    System.Threading.Thread.Sleep(1000);
                    Application.RunOnMainThread(() =>
                    {
                        try
                        {
                            for (int i = 0; i < middViewLayout.ChildrenCount; i++)
                            {
                                RowLayout view = (RowLayout)middViewLayout.GetChildren(i);
                                var volIconBtn = (Button)view.GetChildren(0);//直接FrameLayout父控件找到该控件Button
                                var songNameBtn = (Button)view.GetChildren(1);//直接FrameLayout父控件找到该控件Button
                                var artistNameBtn = (Button)view.GetChildren(2);//直接FrameLayout父控件找到该控件Button
                                if (a31MusicModel.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
                                {
                                    volIconBtn.Visible = true;
                                    songNameBtn.TextColor = UI.Music.Color.SelectedColor;
                                    songNameBtn.X = Application.GetRealWidth(48);
                                    artistNameBtn.X = songNameBtn.Right;
                                    artistNameBtn.TextColor = UI.Music.Color.SelectedColor;
                                }
                                else
                                {
                                    volIconBtn.Visible = false;
                                    songNameBtn.TextColor = UI.Music.Color.MusicTxet14Color;
                                    songNameBtn.X = Application.GetRealWidth(16);
                                    artistNameBtn.X = songNameBtn.Right;
                                    artistNameBtn.TextColor = UI.Music.Color.MusicNoTxetColor;
                                }
 
 
                            }
                        }
                        catch { }
 
                    });
                }
            });
            updateSelectedMusicThread.Start();
        }
    }
}