How to stream videos in java play framework V2.1.3

1,080 views
Skip to first unread message

Sri harsha Bhasuru

unread,
May 13, 2014, 3:44:36 AM5/13/14
to play-fr...@googlegroups.com
Hi,

I am using Java Playframework V2.1.3 . I thought we can use the videos directly placing them in the public folder and then providing the url in the html file.

Below is the piece of code which I am using. In desktop it doesnt stream but pauses till the file content is downloaded and then it plays the video. In iPad it doesn't play the video instead it just shows like a poster with unable to play logo

Code in the html page:

<video controls="controls" style="width:800px">
<source src="/myApp/assets/videos/My_Movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>


Please help me in this thanks!!!

Yann Simon

unread,
May 13, 2014, 3:50:50 AM5/13/14
to play-fr...@googlegroups.com
I made a controller in scala to stream HTML5 videos:

It would need some adaptation / tests but it is maybe a good start for you.

Cheers,
Yann


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sri harsha Bhasuru

unread,
May 13, 2014, 3:56:57 AM5/13/14
to play-fr...@googlegroups.com
Hi Yann 

Thanks for the reply I am Play Java Developer will try to convert this scala to java and will try . Thanks!!!

Yann Simon

unread,
May 13, 2014, 4:01:06 AM5/13/14
to play-fr...@googlegroups.com
OK.

But you know you can mix one controller in scala in a java project?

Sri harsha Bhasuru

unread,
May 13, 2014, 4:05:42 AM5/13/14
to play-fr...@googlegroups.com
You say I can use this scala code in my Java Controller without conversion? or use this scala file placing in Controllers package and then configuring it in routes ? If it is I am not really aware of it

Yann Simon

unread,
May 13, 2014, 4:51:10 AM5/13/14
to play-fr...@googlegroups.com
yes, you can add a scala file in controllers package and configure it in routes.

Anton Kulaga

unread,
May 13, 2014, 5:24:45 AM5/13/14
to play-fr...@googlegroups.com
Quite nice, what about the opposite (streaming webcam video to the server for realtime analysis)?

Xi Shen

unread,
Apr 27, 2015, 2:46:17 AM4/27/15
to play-fr...@googlegroups.com
Hi Yann,

I adopted your method, but I cannot play the video in the browser. If I download the video, it can be played in the OS player. More detail at https://stackoverflow.com/questions/29888652/how-to-stream-video-with-play-2-framework.

Please help me understand the issue.


Thanks,
David

Yann Simon

unread,
Apr 27, 2015, 3:23:12 AM4/27/15
to play-fr...@googlegroups.com
Hi,

there are several possibilities:
- the video can be encoded a way the browser cannot understand it. Be careful, there are three formats: the container, the video and the sound.
- the response from play cannot be understood by the browser. You can check this yourself with tools like curl to make a GET request with a range to see if it is working.



Reply all
Reply to author
Forward
0 new messages