boolean file_ext_create(void* user_data) { file_info_struct* data_file = (file_info_struct*)user_data; VMCHAR filename[VM_FS_MAX_PATH_LENGTH] = {0}; VMWCHAR wfilename[VM_FS_MAX_PATH_LENGTH] = {0}; VM_FS_HANDLE filehandle = -1; sprintf((char*)filename, "%c:\\%s", vm_fs_get_internal_drive_letter(), data_file->filename); vm_chset_ascii_to_ucs2(wfilename, sizeof(wfilename), filename); if((filehandle = vm_fs_open(wfilename, VM_FS_MODE_CREATE_ALWAYS_WRITE, TRUE)) < 0) { vm_log_info("Failed to create file: %s",filename); //Serial1.print("Failed to create file.\r\n"); return true; } vm_log_info("Success to create file: %s", filename); data_file->handle = filehandle; return true; }
VMUINT8 audioPlay(StorageEnum drv, VMINT8 *songName) { VMWCHAR path[256]; VMCHAR path_a[256]; vm_audio_play_parameters_t play_parameters; VM_AUDIO_VOLUME volume; strcpy((char*)m_path, songName); m_drv = drv; m_type = TRUE; if(m_drv == 0) { drv = vm_fs_get_internal_drive_letter(); } else { drv = vm_fs_get_removable_drive_letter(); } if(drv >= 0) { if(m_type) { sprintf(path_a,(const signed char*)"%c:\\%s", drv, (VMINT8*)m_path); vm_chset_ascii_to_ucs2(path, 256, path_a); } else { sprintf(path_a,(const signed char*)"%c:\\", drv); vm_chset_ascii_to_ucs2(path, 256, path_a); vm_wstr_concatenate(path, (VMWSTR)m_path); } } else { vm_log_info("AudioPlay get driver error"); return FALSE; } // set play parameters memset(&play_parameters, 0, sizeof(vm_audio_play_parameters_t)); play_parameters.filename = path; play_parameters.reserved = 0; // play_parameters.format = VM_AUDIO_FORMAT_MP3; // //play_parameters.output_path = VM_AUDIO_DEVICE_SPEAKER2; //play_parameters.output_path = VM_AUDIO_DEVICE_LOUDSPEAKER; play_parameters.output_path = VM_AUDIO_DEVICE_SPEAKER_BOTH; play_parameters.async_mode = 0; play_parameters.callback = audio_play_callback; play_parameters.user_data = &status_result; g_handle = vm_audio_play_open(&play_parameters); if(g_handle >= VM_OK) { vm_log_info("open success"); //*res = 0; } else { vm_log_info("open failed"); //*res = -1; return FALSE; } // start to play vm_audio_play_start(g_handle); // set volume // vm_audio_set_volume(VM_AUDIO_VOLUME_6); // register interrupt callback g_interrupt_handle = vm_audio_register_interrupt_callback(audio_play_callback,&status_result); }