Use automatic navigation
[Examples]

If you want to play all files (*.mp3 and *.mp2) available in all disks or one disk :
use_explorer()
{
   Navauto_mov_state status_mov;
   _MEM_TYPE_SLOW_   U8    ext_filemusic[]    = "mp3,mp2";
   
   // Init explorer mode
   navauto_init( ext_filemusic );         // Init filter to use 
   navauto_setmode( NAVAUTO_MODE_DISK );  // Scan only the current disk (sub folder include)
   navauto_setrand( NAVAUTO_RAND_OFF );   // Init random mode

   nav_select(0);                         // Choose a free navigator
   
   // Select your disk
   nav_drive_set(1);
   nav_partition_mount();
      
   // Open automatic navigation
   // This one take the current position to init the file list
   if( !navauto_open( FALSE, 0 ))             // Here, the folder level param is ignored because the mode disk is selected
      return FALSE;

   // NOW EXPLORER
   do
   {
      // HERE a file is selected
      // You can play file or display file or ...
   
      // Play file finish then go to next
      status_mov = navauto_mov( FS_FIND_NEXT );      
      if( NAVAUTO_MOV_OK_LOOP  == status_mov )
      {
         if( FALSE == repeat_mode )
            break; // Exit loop
      }
   }while(  (NAVAUTO_MOV_OK       == status_mov )
   ||       (NAVAUTO_MOV_OK_LOOP  == status_mov ) );

   switch( status_mov )
   {
      case NAVAUTO_MOV_OK_LOOP:         // End of loop
      case NAVAUTO_MOV_EMPTY:           // loop empty
      case NAVAUTO_MOV_DISKNOPRESENT:   // All disks or a disk is not present (depends of NAVAUTO_MODE)
      case NAVAUTO_MOV_DISKERROR:       // Access error on all or one disk (depends of NAVAUTO_MODE)
   }
   navauto_close();
}

If you want to play all files (*.mp3 and *.mp2) available in a first dir (and subdir) :

use_explorer()
{
   Navauto_mov_state status_mov;
   _MEM_TYPE_SLOW_   U8    ext_filemusic[]    = "mp3,mp2";
   
   // Init explorer mode
   navauto_init( ext_filemusic );         // Init filter to use 
   navauto_setmode( NAVAUTO_MODE_DIRSUB );// Scan folder and sub folder
   navauto_setrand( NAVAUTO_RAND_OFF );   // Init random mode

   nav_select(0);                         // Choose a free navigator
   
   // Enter in first dir of a disk
   nav_drive_set(1);
   nav_partition_mount();
   nav_filelist_first( FS_DIR );
   nav_dir_cd();
   
   // Explore current dir and sub dir
   if( !navauto_open( FALSE , 0 ))        // The param folder level is 0 because the current folder is the base of navigation
      return FALSE;

   // NOW EXPLORER
   do
   {
      // HERE a file is selected
      // You can play file or display file or ...
   
      // Play file finish then go to next
      status_mov = navauto_mov( FS_FIND_NEXT );      
      if( NAVAUTO_MOV_OK_LOOP  == status_mov )
      {
         if( FALSE == repeat_mode )
            break; // Exit loop
      }
   }while(  (NAVAUTO_MOV_OK       == status_mov )
   ||       (NAVAUTO_MOV_OK_LOOP  == status_mov ) );

   switch( status_mov )
   {
      case NAVAUTO_MOV_OK_LOOP:         // End of loop
      case NAVAUTO_MOV_EMPTY:           // loop empty
      case NAVAUTO_MOV_DISKNOPRESENT:   // All disks or a disk is not present (depends of NAVAUTO_MODE)
      case NAVAUTO_MOV_DISKERROR:       // Access error on all or one disk (depends of NAVAUTO_MODE)
   }
   navauto_close();
}

If you want to play all files available in a playlist :

use_explorer()
{
   Navauto_mov_state status_mov;
   const _MEM_TYPE_SLOW_ U8 name[]="playlist.mu3";
   
   // Init explorer mode
   //navauto_init( ext_filemusic );          // Init filter to use, NO USED in play list
   //navauto_setmode( NAVAUTO_MODE_DIRSUB ); // Scan folder and sub folder, NO USED in play list
   navauto_setrand( NAVAUTO_RAND_OFF );      // Init random mode
   
   nav_select(0);                            // Choose a free navigator
   
   // Select your play list file
   nav_drive_set(1);
   nav_partition_mount();
#if( (FS_ASCII == ENABLED) && (FS_UNICODE == ENABLED) )
   nav_string_ascii();  // Select a ASCII name format
#endif
   if( !nav_filelist_findname( (FS_STRING)name , FALSE ) )   // search file "playlist.mu3" in root dir
      return FALSE;
   
   // Explore all disks available
   if( !navauto_open( TRUE , 0 ))            // param O to select the first file of the play list
      return FALSE;

   // NOW EXPLORER
   do
   {
      // HERE a file is selected
      // You can play file or display file or ...
   
      // Play file finish then go to next
      status_mov = navauto_mov( FS_FIND_NEXT );      
      if( NAVAUTO_MOV_OK_LOOP  == status_mov )
      {
         if( FALSE == repeat_mode )
            break; // Exit loop
      }
   }while(  (NAVAUTO_MOV_OK       == status_mov )
   ||       (NAVAUTO_MOV_OK_LOOP  == status_mov ) );

   switch( status_mov )
   {
      case NAVAUTO_MOV_OK_LOOP:         // End of loop
      case NAVAUTO_MOV_EMPTY:           // loop empty
      case NAVAUTO_MOV_DISKNOPRESENT:   // All disks or a disk is not present (depends of NAVAUTO_MODE)
      case NAVAUTO_MOV_DISKERROR:       // Access error on all or one disk (depends of NAVAUTO_MODE)
   }
   navauto_close();
}

If you want to save and restore a automatic navigation (e.g. save before Power OFF and restore after power ON):

power_off()
{
   setting_field.navauto_mode = navauto_getmode(); // Get explorer mode
   setting_field.navauto_rand = navauto_getrand(); // Get random mode
   setting_field.navauto_pos  = navauto_close();   // Get current dir level         or playlist position
   setting_field.nav_index    = nav_getindex();    // Get current position in disk  or playlist file index

   setting_save();
}

power_on()
{
   _MEM_TYPE_SLOW_   U8    ext_filemusic[]    = "mp3,mp2";
   setting_load();
   
   // Restore navigation configuration
   navauto_init( ext_filemusic );
   navauto_setmode( setting_field.navauto_mode );
   navauto_setrand( setting_field.navauto_rand );
  
   // Restore navigation position
   nav_select(0)  
   // Go to last position in disk or go to paly list file
   nav_gotoindex( &setting_field.nav_index );
   // Restore navigation with the last directory level or last playlist position
   if( !navauto_open( nav_file_checkext(ext_playlist) , setting_field.navauto_pos ))
      return FALSE;
}

Generated on Wed Sep 23 09:17:19 2009 for ATMEL by  doxygen 1.5.3