1<html> 2 3<head> 4<title>vorbisfile - seeking_test.c</title> 5<link rel=stylesheet href="style.css" type="text/css"> 6</head> 7 8<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> 9<table border=0 width=100%> 10<tr> 11<td><p class=tiny>Vorbisfile documentation</p></td> 12<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td> 13</tr> 14</table> 15 16<h1>seeking_test.c</h1> 17 18<p> 19The example program source: 20 21<br><br> 22<table border=0 width=100% color=black cellspacing=0 cellpadding=7> 23<tr bgcolor=#cccccc> 24 <td> 25<pre><b> 26 27#include <stdlib.h> 28#include <stdio.h> 29#include "vorbis/codec.h" 30#include "vorbis/vorbisfile.h" 31 32int main(){ 33 OggVorbis_File ov; 34 int i; 35 36#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */ 37 _setmode( _fileno( stdin ), _O_BINARY ); 38#endif 39 40 /* open the file/pipe on stdin */ 41 if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)==-1){ 42 printf("Could not open input as an OggVorbis file.\n\n"); 43 exit(1); 44 } 45 46 /* print details about each logical bitstream in the input */ 47 if(ov_seekable(&ov)){ 48 double length=ov_time_total(&ov,-1); 49 printf("testing seeking to random places in %g seconds....\n",length); 50 for(i=0;i<100;i++){ 51 double val=(double)rand()/RAND_MAX*length; 52 ov_time_seek(&ov,val); 53 printf("\r\t%d [%gs]... ",i,val); 54 fflush(stdout); 55 } 56 57 printf("\r \nOK.\n\n"); 58 }else{ 59 printf("Standard input was not seekable.\n"); 60 } 61 62 ov_clear(&ov); 63 return 0; 64} 65 66</b></pre> 67 </td> 68</tr> 69</table> 70 71 72<br><br> 73<hr noshade> 74<table border=0 width=100%> 75<tr valign=top> 76<td><p class=tiny>copyright © 2007 Xiph.org</p></td> 77<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td> 78</tr><tr> 79<td><p class=tiny>Vorbisfile documentation</p></td> 80<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td> 81</tr> 82</table> 83 84</body> 85 86</html> 87