MediaPlayer error: The byte stream type of the given URL is unsupported. (Exception from HRESULT: 0xC00D36C4)

0

I am new to UWP. I am recording voice input (with MediaCapture) and then I trying to play it back.

And I am getting the following error

The byte stream type of the given URL is unsupported. (Exception from HRESULT: 0xC00D36C4)

I create is an MP3 file that can be play by double click with player. So the file is 'ok'.

When I try to play it with MediaPlayer I get that error. I tried installing a new codec package and pointed .mp3 at it. Same error. I tried streams, StorageFile and URL methods for defining the input file but always the same error. I have microphone and webcam enabled. (my microphone is in the webcam) I am deploying to 'Local Machine'. Anyone know a possible reason? Here is the code. I would be interested to see if it works on another PC.

    private async void RecordAndPlay()
    {
        string mediaFilename = "audioPRC.mp3";
        StorageFile mediaFile;
        StorageFolder tempFolder;
        MediaCapture mediaCapture;
        MediaPlayer mediaPlayer = null;
        LowLagMediaRecording lowLagMediaRecording;
        MediaSource mediaSource;
        mediaCapture = new MediaCapture();
        await mediaCapture.InitializeAsync();
        mediaCapture.Failed += OnMediaCaptureFailed;
        tempFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;
        mediaFile = await tempFolder.CreateFileAsync(mediaFilename, CreationCollisionOption.ReplaceExisting);
        MediaEncodingProfile mediaEncodingProfile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.Medium);
        lowLagMediaRecording = await mediaCapture.PrepareLowLagRecordToStorageFileAsync(
                mediaEncodingProfile, mediaFile);
        await lowLagMediaRecording.StartAsync();
        // Talk into your microphone during the 10 second wait...
        await Task.Delay(10000);
        await lowLagMediaRecording.StopAsync();
        await lowLagMediaRecording.FinishAsync();
        lowLagMediaRecording = null;
        mediaPlayer = new MediaPlayer { AutoPlay = false, AudioCategory = MediaPlayerAudioCategory.Media };
        mediaPlayer.MediaFailed += OnMediaPlayerFailed;
        mediaPlayer.AudioCategory = Windows.Media.Playback.MediaPlayerAudioCategory.Media;
        mediaSource = MediaSource.CreateFromStorageFile(mediaFile);
        var mediaPlaybackItem = new MediaPlaybackItem(mediaSource);
        mediaPlayer.Source = mediaPlaybackItem;
        mediaPlayer.Play();
    }
    private void OnMediaPlayerFailed(object sender, MediaPlayerFailedEventArgs e)
    { Debug.WriteLine(e.ExtendedErrorCode.Message); }
    private void OnMediaCaptureFailed(MediaCapture sender, MediaCaptureFailedEventArgs e)
    { Debug.WriteLine("Capture failed: " + e.Message); }
uwp
media-player
mediaplayback
asked on Stack Overflow Mar 24, 2017 by Paulustrious • edited Mar 27, 2017 by lindexi

1 Answer

0

I changed the encoding to a wav file and it all worked. It hasn't really answered the question of why mp3 is failing. Two lines of code changed were:

        string mediaFilename = "audioPRC.wav";
        MediaEncodingProfile mediaEncodingProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Auto);
answered on Stack Overflow Mar 25, 2017 by Paulustrious

User contributions licensed under CC BY-SA 3.0