seeking_example_c.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <html>
  2. <head>
  3. <title>vorbisfile - seeking_test.c</title>
  4. <link rel=stylesheet href="style.css" type="text/css">
  5. </head>
  6. <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
  7. <table border=0 width=100%>
  8. <tr>
  9. <td><p class=tiny>vorbisfile documentation</p></td>
  10. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  11. </tr>
  12. </table>
  13. <h1>seeking_test.c</h1>
  14. <p>
  15. The example program source:
  16. <br><br>
  17. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  18. <tr bgcolor=#cccccc>
  19. <td>
  20. <pre><b>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include "vorbis/codec.h"
  24. #include "vorbis/vorbisfile.h"
  25. #include "../lib/misc.h"
  26. int main(){
  27. OggVorbis_File ov;
  28. int i;
  29. /* open the file/pipe on stdin */
  30. if(ov_open(stdin,&ov,NULL,-1)==-1){
  31. printf("Could not open input as an OggVorbis file.\n\n");
  32. exit(1);
  33. }
  34. /* print details about each logical bitstream in the input */
  35. if(ov_seekable(&ov)){
  36. double length=ov_time_total(&ov,-1);
  37. printf("testing seeking to random places in %g seconds....\n",length);
  38. for(i=0;i<100;i++){
  39. double val=(double)rand()/RAND_MAX*length;
  40. ov_time_seek(&ov,val);
  41. printf("\r\t%d [%gs]... ",i,val);
  42. fflush(stdout);
  43. }
  44. printf("\r \nOK.\n\n");
  45. }else{
  46. printf("Standard input was not seekable.\n");
  47. }
  48. ov_clear(&ov);
  49. return 0;
  50. }
  51. </b></pre>
  52. </td>
  53. </tr>
  54. </table>
  55. <br><br>
  56. <hr noshade>
  57. <table border=0 width=100%>
  58. <tr valign=top>
  59. <td><p class=tiny>copyright &copy; 2000 vorbis team</p></td>
  60. <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>
  61. </tr><tr>
  62. <td><p class=tiny>vorbisfile documentation</p></td>
  63. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  64. </tr>
  65. </table>
  66. </body>
  67. </html>