locked
Live tile name song RRS feed

  • Domanda

  • Salve, ho un problema con una live tile. Io ho un app che riproduce suoni attraverso l'audio player di default. Io vorrei mostrare nella live tile il nome del suono (nome del file audio) nella live tile. Nella MainPage.xaml.cs ho usato:

    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);
            }
    
    
        }

    e in MainPage.xaml:

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

    Nella pagina principale dell'app (quando viene eseguita), il "titolo" (nome del file) appare, invece nella live tile non appare. Se possibile potreste spiegare il problema riscontrato e magari aiutarmi a risolverlo? Thnx to all

    EDIT:

    Ho settato txtcurrentTrack.Text qui (nella MainPage.xaml.cs):

    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 = "";
            }
        }


    giovedì 9 agosto 2012 23:33