×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2014
    Posts
    10

    Question What do that to load file .mp3 on device to listbox

    Code:
    public class songmodel
            {
                public int songid { get; set; }
                public int song { get; set; }
            }
            private async void filehasDownloaded()
            {
                var filelist = new List<songmodel>();
                var file = await KnownFolders.MusicLibrary.GetFilesAsync(CommonFileQuery.OrderByName);
                
               
            }

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,026

    Re: What do that to load file .mp3 on device to listbox

    What does the following statement returns : var file = await KnownFolders.MusicLibrary.GetFilesAsync(CommonFileQuery.OrderByName);

    Does it crashes or count is 0 if you do file.count()?.
    Edit : Ok i tried running this code and found that 'KnownFolders.MusicLibrary' throws "System.notimplementedexception'

    and then followed post #2 here :
    http://stackoverflow.com/questions/1...ia-file-access
    Last edited by vineet.jain; 2014-06-18 at 06:32.

  3. #3
    Registered User
    Join Date
    Apr 2014
    Posts
    10

    Question How to load information to class when loaded information from the device?????????????

    Code:
      public class songmodel
            {
                public int songid { get; set; }
                public string song { get; set; }
            }
            private async void filehasDownloaded()
            {
                //var filelist = new List<songmodel>();
                IReadOnlyList<StorageFile> files = await KnownFolders.MusicLibrary.GetFilesAsync(CommonFileQuery.OrderByName);
                lstdownload.ItemsSource = files;
                lstdownload.DisplayMemberPath = "Name";
                foreach(StorageFile f in files)
                {
                    var stream = await f.OpenAsync(FileAccessMode.Read);
                    if (lstdownload.SelectedIndex != -1)
                    {
                        //.Play();
                        mymedia.SetSource(stream, f.ContentType);
                        mymedia.Play();
                    }
                }
              
                    
                
                
               
            }
    How do load information to class songmodel???????????????

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,026

    Re: How to load information to class when loaded information from the device?????????

    Well you need to create a new object of class songmodel, each time you want to store the song data and then keep on adding that object to a list.

    Code:
    songmodel _isongmodel = new songmodel()
    _isongmodel. songid = value;
    _isongmodel. songid = song ;
    ListObject.Add(_isongmodel );
    Keep this code inside foreach at the end of each iteration

  5. #5
    Registered User
    Join Date
    Apr 2014
    Posts
    10

    Re: How to load information to class when loaded information from the device?????????

    You know why my code is not playing?? It just show to listbox but not playing .

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: How to load information to class when loaded information from the device?????????

    So far you seem to have a loop which either does nothing, or starts playing all of your music files simultaneously, depending on the condition "lstdownload.SelectedIndex != -1". I would likely vote for the former, as based on your question that list may be very well empty.
    Note that it is not shown in your snippet what lstdownload or mymedia actually are.

    EDIT: the two threads are merged now.
    Last edited by wizard_hu_; 2014-06-22 at 20:03.

Similar Threads

  1. Load online XML problem: Device vs. Device Central
    By davyhoskens in forum [Archived] Flash Lite on Nokia Devices
    Replies: 7
    Last Post: 2010-11-09, 04:00
  2. Load sms in a listbox
    By adhossain in forum Symbian
    Replies: 5
    Last Post: 2010-07-22, 08:37
  3. How to Load all '.mp3 ' files into a ListBox
    By vijaysoft in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-06-28, 20:31
  4. How to load a .png image file in device?
    By sungodjava in forum Mobile Java General
    Replies: 3
    Last Post: 2007-08-03, 13:58
  5. Load RSC String in a Listbox
    By dokkis in forum Symbian
    Replies: 1
    Last Post: 2007-05-31, 06:07

Posting Permissions

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