Beispiel #1
0
    public bool Save(string filename, AudioClip clip)
    {
        if (!filename.ToLower().EndsWith(".wav"))
        {
            filename += ".wav";
        }

        var filepath = Path.Combine(Application.persistentDataPath, filename);

        Debug.Log("current audio path is " + filepath);

        // Make sure directory exists if user is saving to sub dir.
        Directory.CreateDirectory(Path.GetDirectoryName(filepath));
        Debug.Log("directory created");

        using (var fileStream = CreateEmpty(filepath))
        {
            ConvertAndWrite(fileStream, clip);
            WriteHeader(fileStream, clip);
        }

        Debug.Log("bytes converted");
        byte[] data = File.ReadAllBytes(filepath);
        audioBase64 = System.Convert.ToBase64String(data);

        string answerType = "Audio";

        Debug.Log("saving base64");
        MissionsService.UpdateMissionAnswer(answerType, audioBase64);

        return(true);        // TODO: return false if there's a failure saving the file
    }
Beispiel #2
0
    public void SaveVideo()
    {
        string videoBase64 = camService.videoBase64;

        MissionsService.UpdateMissionAnswer(modalType, videoBase64);

        Destroy();
    }
Beispiel #3
0
    public void SaveText()
    {
        string text = textMsg.text;

        MissionsService.UpdateMissionAnswer(modalType, text);

        Destroy();
    }
Beispiel #4
0
    public void SavePicture()
    {
        string photoBase64 = camService.photoBase64;

        MissionsService.UpdateMissionAnswer(modalType, photoBase64);

        Destroy();
    }
Beispiel #5
0
    public void SaveAudio()
    {
        string audioBase64 = MissionsService.missionAnswer.audio;

        MissionsService.UpdateMissionAnswer(modalType, audioBase64);

        Destroy();
    }
Beispiel #6
0
    public void SaveGeolocation()
    {
        string lat = GPSService.location[0].ToString(),
               lng = GPSService.location[1].ToString();

        MissionsService.UpdateMissionAnswer(modalType, lat, lng);

        Destroy();
    }
Beispiel #7
0
 private void UpdateCurrentSubmission()
 {
     MissionsService.UpdateMissionAnswer(submission);
 }