locked
Windows Phone 8.1 Trimming An MP3

    Question

  • im trying to trim an mp3 file except every time it returns the error bad profile, i have been at this for 2 days, trying every bit of information i can find.

    This is what i have so far. (i know its abit of a mess, i just want to get it working for now)

          
     async void TrimFile()
            {
           
                StorageFolder OutFolder = KnownFolders.MusicLibrary;
                StorageFile OutFile = await OutFolder.GetFileAsync("test.mp3");
                var destFile = OutFile;
         
                StorageFolder Infolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile InFile = await Infolder.GetFileAsync("test.mp3");
                var srcFile = InFile;
                   
                MediaEncodingProfile profile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.Low);
               
                MediaTranscoder transcoder = new MediaTranscoder();
           
                transcoder.TrimStartTime = new TimeSpan(0, 0, 2);
       
                transcoder.TrimStopTime = new TimeSpan(0, 0, 5);
           
                PrepareTranscodeResult prepareOp = await transcoder.PrepareFileTranscodeAsync(srcFile, destFile, profile);
                
                if (prepareOp.CanTranscode)
                {
                    var transcodeOp = prepareOp.TranscodeAsync();
                    transcodeOp.Progress += new AsyncActionProgressHandler<double>(TranscodeProgress);
                    transcodeOp.Completed += new AsyncActionWithProgressCompletedHandler<double>(TranscodeComplete);
                }
                else
                {
                    switch (prepareOp.FailureReason)
                    {
                        case TranscodeFailureReason.CodecNotFound:
                            TextBlock1.Text = "No Codec";
                            break;
                        case TranscodeFailureReason.InvalidProfile:
                            TextBlock1.Text = "Invalid Profile";
                            break;
                        default:
    
                            break;
                    }
                }
            }
    


    if someone could help point me in the right direction thanks.
    Wednesday, March 4, 2015 7:41 PM

Answers

All replies