Barra laterale

programmazione:javascript:streaming_ogg_opensource

Streaming ogg Audio/Video opensource

Autore: Fabio Di Matteo
Ultima revisione: 08/08/2009

Quello che serve

  1. Applet java per lo streaming –> Cortado
  2. ffmpeg2theora per convertire i video e audio nel formato ogg (per unix liberi)

Prepariamo un file video di prova

ffmpeg2theora filevideoqualsiasi.avi 

verrà generato un file video .ogg , rinominiamolo video.ogg .

Preparazione html e javascript

Scarichiamo l'applet e rinominiamola in cortado.jar , e mettiamola nella stessa directory del video.

prepariamo la pagina (anche essa da mettere nella stessa directory del video):

        <html>
 	<head>
 	</head>
 	<body>
	<script language="javascript">
 	     function restart() {
 	       document.applets[0].restart();
 	     }
 	     function doPlay() {
 	       document.applets[0].doPlay();
 	     }
		function doStop() {
 	       	document.applets[0].doStop();
 	     }
		function doPause() {
 	       	document.applets[0].doPause();
 	     }
 
 	   </script>
 
 
 	   <applet code="com.fluendo.player.Cortado.class"
 	           archive="cortado.jar"
 	           width="320" height="240">
 	     <param name="url" value="video.ogg"/>
 	     <param name="local" value="false"/>
 	     <param name="duration" value="232"/>
 	     <param name="keepAspect" value="true"/>
 	     <param name="video" value="true"/>
	     <param name="audio" value="true"/>
	     <param name="bufferSize" value="200"/>
             <param name="seekable" value="true"/>
             <param name="showStatus" value="show"/>
	     <param name="userId" value="user"/>
	     <param name="password" value="test"/>
	   </applet>
		<br/>
 	   <br/>
 		<button onClick="restart()">
 	    	Riavvia
	   	</button>	
		<button onClick="doPlay()">
 	    	Play
	   	</button>
		<button onClick="doPause()">
 	    	Pausa
	   	</button>
		<button onClick="doStop()">
 	    	Stop
	   	</button>
 	</body>
 	</html>

Altri parametri da passare all'applets

I parametri all'applets si passano in questa maniera:

<param name="parametro" value="valore parametro"/>

Gli altri possibili valori possono essere i seguenti presi dal [https://code.fluendo.com/flumotion/trac/browser/cortado/trunk/README|README originale]]

          url:        string
 	              the URL to load, must be a fully qualified URL.
 	              IMPORTANT: if the applet is not signed, the hostname of the
 	              url *is required* to be the same as the hostname of the link
 	              to the page with the applet tag.  This is a Java security limitation.
 	
 	  seekable:   enum (auto|true|false)
 	              Whether or not you can seek in the file.  For live streams,
 	              this should be false; for on-demand files, this can be true.
 	              In automatic mode, the stream becomes seekable when the content
 	              length is discovered.
 	              Defaults to auto
 	
 	  live        enum (auto|true|false)
 	              Whether or not this file is a live stream.  For live streams,
 	              this should be true, which will disable the PAUSE button.
 	              For on-demand files, this can be false.
 	              In automatic mode, the stream becomes non-live when the content
 	              length is discovered.
 	              Defaults to auto
 	
 	  duration:   int
 	              Length of clip in seconds.  Needed when seekable is true,
 	              to allow the seek bar to work.
 	
 	  keepAspect: boolean
 	              Try to keep the natural aspect of the video when resizing the
 	              applet window. true or false.
 	              Defaults to true
 	
 	  video:      boolean
 	              Use video. When not using video, this property will not create
 	              resources to play a video stream. true or false.
 	              Defaults to true
 	             
 	  audio:      boolean
 	              Use audio. When not using audio, this property will not create
 	              resources to play an audio stream. true or false.
 	              Defaults to true
 	
 	  statusHeight: int
 	              The height of the status area (default 12)
 	
 	  autoPlay:   boolean
 	              Automatically start playback (default true)
 	
 	  showStatus: enum (auto|show|hide)
 	              Controls how to make the status area visible.
 	              auto will show the status area when hovered over with the mouse.
 	              hide will only show the status area on error.
 	              show will always show the status area.
 	              (default auto)
 	
 	  hideTimeout: int
 	              Timeout in seconds to hide the status area when showStatus is
 	              auto. This timeout is to make sure that the status area is visible
 	              for the first timeout seconds of playback so that the user can see
 	              that there is a clickable status area too.
 	              (default 0)
 	
 	  bufferSize: int
 	              The size of the network buffer, in KB.
 	              A good value is max Kbps of the stream * 33
 	              Defaults to 200
 	
 	  bufferLow:  int
 	              Percentage of low watermark for buffer.  Below this, the applet
 	              will stop playing and rebuffer until the high watermark is
 	              reached.
 	              Defaults to 10
 	
 	  bufferHigh: int
 	              Percentage of high watermark for buffer.  At startup or when
 	              rebuffering, the applet will not play until this percentage of
 	              buffer fill status is reached.
 	              Defaults to 70
 	
 	  userId:     string
 	              user id for basic authentication.
 	
 	  password:   string
 	              password for basic authentication.
 	
 	  debug:      int
 	              debug level, 0 - 4.  Defaults to 3.  Output goes to the Java
 	              console.
 	

programmazione/javascript/streaming_ogg_opensource.txt · Ultima modifica: 18/04/2018 - 15:48 (modifica esterna)