簡體   English   中英

現場瓷磚名稱歌曲

[英]Live tile name song

我的活動瓷磚有問題。 我會在我的應用程序中以實時聲音的形式顯示生成聲音的歌曲名稱。 我在MainPage.xaml.cs中使用了:

public MainPage()
    {
        InitializeComponent();
        // Application Tile is always the first Tile, even if it is not pinned to Start.
        ShellTile TileToFind = ShellTile.ActiveTiles.First();

        // Application should always be found
        if (TileToFind != null)
        {
            // if Count was not entered, then assume a value of 0

            // set the properties to update for the Application Tile
            // Empty strings for the text values and URIs will result in the property being cleared.
            StandardTileData NewTileData = new StandardTileData
            {
                Title = "MyNameApp",
                BackgroundImage = new Uri("Red.jpg", UriKind.Relative),

                BackTitle = "Zzz...",
                BackBackgroundImage = new Uri("Green.jpg", UriKind.Relative),
                BackContent = txtCurrentTrack.Text <<HERE MY PROBLEM
            };

            // Update the Application Tile
            TileToFind.Update(NewTileData);
        }


    }

並在MainPage.xaml中:

<TextBlock x:Name="txtCurrentTrack" Height="75" HorizontalAlignment="Center" Margin="12,193,0,0" VerticalAlignment="Top" Width="438" TextWrapping="Wrap"/>

在App的MainPage中,歌曲標題出現,而不是在實時圖塊中出現。 你知道是什么問題嗎? 向所有人致謝

編輯:

我在此處(在MainPage.xaml.cs中)設置了txtcurrentTrack.Text:

void Instance_PlayStateChanged(object sender, EventArgs e)
    {
        switch (BackgroundAudioPlayer.Instance.PlayerState)
        {
            case PlayState.Playing:
                RelaxTB.Content = "pause";
                break;

            case PlayState.Paused:
            case PlayState.Stopped:
                RelaxTB.Content = "play";
                break;
        }
        if (null != BackgroundAudioPlayer.Instance.Track)
        {
            txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title;
        }
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
        {
            RelaxTB.Content = "Pause";
            txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title;

        }
        else
        {
            RelaxTB.Content = "Play";
            txtCurrentTrack.Text = "";
        }
    }

在更新切片數據時,似乎沒有設置txtCurrentTrack上的Text屬性。 因此,您只能將BackContent屬性設置為null。

You need to update the tile explicitly each time you change txtCurrentTrack.Text ,都需要在Instance_PlayStateChanged和OnNavigatedTo方法中You need to update the tile explicitly each time you change txtCurrentTrack.Text磁貼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM