title: "audio/mpeg" stream api fails for some files plays some files?
body: <p>We are recording some audios on Android phones which are having the following format as per vlc information: </p>
  
  <pre><code>Codec: MPEG AAC Audio (mp4a)
  Language: English
  Type: Audio
  Channels: Stereo
  Sample rate: 32000 Hz
  Bits per sample: 32
  </code></pre>
  
  <p>The above files were not playing on the safari browser with mime type <code>audio/mpeg</code>, But as soon as we changed the mime to <code>audio/mp4</code> it started playing on safari browser.
  For Android we are using API to stream this file using api resource as follows :</p>
  
  <pre><code>@GET
      @UnitOfWork
      @Produces("audio/mpeg")
      @Path("/getaudiofile/{fileId}")
      public Response getPart(@Auth AuthUser authUser, @PathParam("fileId") Long fileId) {
  
   File audioFile = new File(filesTableDAO.getFilePathById(fileId));
  
  if(audioFile.exists()) {
  return Response.ok().entity(audioFile).build();
  } else {
  // ... Return 404 here
  }
  
  }
  </code></pre>
  
  <p>But with above API some files getting played &amp; some are not, Similar to Safari case earlier. But safari problem went away ASAP we changed mime to <code>"audio/mp4"</code> or <code>"video/mp4"</code> both the mime type work.</p>
  
  <p>But for the API <code>/getaudiofile/{fileId}</code> none of the following mime types worked with the <code>javax.ws.rs @Produces</code> annotaion :</p>
  
  <pre><code>    audio/mp4
      video/mp4
      audio/mpeg
      audio/m4a
      audio/mpeg-4
  audio/mp4a
  </code></pre>
  
  <p>But with <code>audio/mpeg</code> some of the files play but some don't.</p>
  
  <p>What may be the right mime type or can file set the codec or mime info itself while returning from API ?</p>
  
  <p>Or Is there any way to make <a href="https://developer.android.com/reference/android/media/MediaPlayer" rel="nofollow noreferrer">Android Media Player</a> MIME type aware? Like <a href="https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_audio_all" rel="nofollow noreferrer"> html tag</a>.</p>
  
  <p>We have streamed file content of mime "audio/mpeg" the media player plays smaller sized files easily. But bigger streamed content fails to play e.g. 10 - 20 MB.</p>
  
  <p>Problem with stream URL the player do not get any mime extension e.g. mp3, or mp4. Hence we want the media player to know in advance what type of the content is being streamed.</p>
  
  <p>Does the MediaPlayer API support setting mime type to player instance prior to playing?</p>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>1] This is happening for files with big sizes small files play very well, An recording of few seconds ( 1-50 secs ) play without a problem, An recording file with playback length of more than minute fails to play.</p>
  
  <p>2] When played from authenticated URL playback fails if the same file is on local file system plays flawlessly.</p>