×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    2

    how to play a sample Track using nokia music api

    I write this code to play sample song using nokia mixradio api bt it does not work pls help me.

    MediaElement mysound = new MediaElement();
    MusicClient musicClient = new MusicClient("554677093f07509567a1e4bbe385d9f2");
    var result = await musicClient.SearchAsync(sname + " " + artistname, Category.Track);
    myimage2 = new BitmapImage(result[0].Thumb320Uri);
    var trackuri = musicClient.GetTrackSampleUri(result[0].Id);
    mysound.Source = new Uri(trackuri.AbsoluteUri);


    private void playonclick(object sender, EventArgs e)
    {
    mysound.Play();
    }

  2. #2
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    73

    Re: how to play a sample Track using nokia music api

    For me, I have had to set the MediaElement AutoPlay property to True and have the MediaElement declared in XAML - see http://developer.nokia.com/Community...l=1#post923655
    Regards,
    Steve

  3. #3
    Registered User
    Join Date
    Dec 2013
    Posts
    2

    Re: how to play a sample Track using nokia music api

    Hi Steve,
    I have the same roblem.

    I tried to play a sample track. The AutoPlay is set to true.
    But it doesnt start.
    MediaElement changes state to opening and after that the state is immediately switched to closed.

    Regards
    Ian

  4. #4
    Nokia Developer Expert
    Join Date
    Feb 2014
    Posts
    29

    Re: how to play a sample Track using nokia music api

    Quote Originally Posted by ianwinslow View Post
    Hi Steve,
    I have the same roblem.

    I tried to play a sample track. The AutoPlay is set to true.
    But it doesnt start.
    MediaElement changes state to opening and after that the state is immediately switched to closed.

    Regards
    Ian
    Is the MediaElement declared in XAML or in code? I've only had it work declaring it in XAML - this could be in you App.xaml or the specific page.
    Regards,
    Steve

  5. #5
    Registered User
    Join Date
    Feb 2014
    Posts
    5

    Lightbulb Re: how to play a sample Track using nokia music api

    For me having the MediaElement declared in XAML did the trick, thank you for the hint!
    For who can't have it working, I post my code:
    MainPage.xaml:
    Code:
    ...
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <MediaElement Name="musicPlayer" AutoPlay="True" />
    </Grid>
    ...
    MainPage.xaml.cs:
    Code:
    ...
            // Constructor
            public MainPage()
            {
                InitializeComponent();
    
                musicClient = new MusicClient(ClientId); // change ClientId with the string of your MixRadio API Client ID
                Test();
            }
    
            private async void Test()
            {
                ListResponse<MusicItem> result = await musicClient.SearchAsync("American Idiot", Category.Track);
                Uri trackUri = musicClient.GetTrackSampleUri(result[0].Id);
                musicPlayer.Source = new Uri(trackUri.AbsoluteUri);
                musicPlayer.Play();
            }
    ...
    When I run the app, American Idiot by Green Day starts.

  6. #6
    Registered User
    Join Date
    Dec 2013
    Posts
    2

    Re: how to play a sample Track using nokia music api

    It works!

    It was not the mediaelemt.
    I passed the wrong ID.

    Thanks
    ian

Similar Threads

  1. nokia music not available in this locale? (Music Explorer Sample)
    By roschler in forum Windows Phone General
    Replies: 5
    Last Post: 2013-04-02, 14:39
  2. Error playing multi-track sp midi files on S60 devices. Old nokia phones used to play
    By kishban in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-01-21, 10:29
  3. How to play Music using xHTML in Nokia 3650
    By asrao_adi in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2003-11-17, 13:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×