I'm trying to stream a mp4 file to iOS devices (iPhone and iPad) from a Grails controller:
def streamContent() {
def contentPath = "/path/to/file"
File f = new File(contentPath)
if(f.exists()) {
response.setContentType("video/mp4")
response.outputStream << f.newInputStream()
response.outputStream.flush()
response.outputStream.close()
} else {
render status: 404
}
}
this code works well on desktop browsers like safari (I see the video), but when I access to the same page with an iPhone or an iPad the video won't play. Note that if I put the same video on Apache httpd and I request it from iOS devices, there is no problem. So it must be a streaming problem.
On the html page the video is embedded using HTML5 video tag:
<video width="360" height="200" controls>
<source src="http://localhost:8080/myapp/controller/streamContent" type='video/mp4'>
</video>