~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to mpeglib_artsplug/so_play.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  testprogramm for arts streaming
3
 
  Copyright (C) 2001  Martin Vogt
4
 
 
5
 
  This program is free software; you can redistribute it and/or modify
6
 
  it under the terms of the GNU Library General Public License as published by
7
 
  the Free Software Foundation.
8
 
 
9
 
  For more information look at the file COPYRIGHT in this package
10
 
 
11
 
 */
12
 
 
13
 
 
14
 
#include "soundserver.h"
15
 
#include "kmedia2.h"
16
 
#include <connect.h>
17
 
 
18
 
#ifdef HAVE_CONFIG_H
19
 
#include "config.h"
20
 
#endif
21
 
 
22
 
#include <stdio.h>
23
 
#include <stdlib.h>
24
 
#include <vector>
25
 
#include <string>
26
 
#include <iostream>
27
 
 
28
 
using namespace std;
29
 
using namespace Arts;
30
 
 
31
 
#if defined(HAVE_GETOPT_H) 
32
 
#include <getopt.h>
33
 
#endif
34
 
 
35
 
//
36
 
// KDE extension
37
 
//
38
 
 
39
 
#include <kurl.h>
40
 
#include <arts/kplayobjectfactory.h>
41
 
 
42
 
void usage() {
43
 
  cout << "libsplayartsplay command line tool for arts playobjects2"<<endl;
44
 
  cout << "Usage : libsplayartsplay [url]"<<endl;
45
 
  cout << endl;
46
 
  cout << "-h : help"<<endl;
47
 
  cout << endl;
48
 
  cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
49
 
       << "USE AT YOUR OWN RISK!"<<endl;
50
 
  cout << endl;
51
 
  exit(0);
52
 
}
53
 
 
54
 
 
55
 
int main(int argc, char **argv) {
56
 
  int c;
57
 
 
58
 
  while(1) { 
59
 
    c = getopt (argc, argv, "h");
60
 
    if (c == -1) break;
61
 
    switch(c) {
62
 
    case 'h': {    
63
 
      usage();
64
 
      exit(0);
65
 
      break;
66
 
    }
67
 
    default:
68
 
      printf ("?? getopt returned character code 0%o ??\n", c);
69
 
      usage();
70
 
      exit(-1);
71
 
    }
72
 
  }
73
 
  if (optind == argc ) {
74
 
    usage();
75
 
    exit(0);
76
 
  }
77
 
 
78
 
  cout << "file:"<<argv[optind]<<endl;
79
 
  string file(argv[optind]);
80
 
 
81
 
  Dispatcher* d=new Dispatcher();
82
 
  Arts::SoundServerV2 server;
83
 
  server = Arts::Reference("global:Arts_SoundServerV2");
84
 
  cout << "4"<<endl;
85
 
  
86
 
  if(server.isNull()) {
87
 
    cerr << "Can't connect to sound server2" << endl;
88
 
    exit(0);
89
 
  }
90
 
  
91
 
  //PlayObject play=server.createPlayObjectForURL(file,"audio/x-mp3",true);
92
 
 
93
 
  FileInputStream fileInputStream;
94
 
 
95
 
  if(!fileInputStream.open(file)) {
96
 
    printf("can't open file %s\n",file.c_str());
97
 
    exit(1);
98
 
  }
99
 
 
100
 
  PlayObject play=server.createPlayObjectForStream(fileInputStream,
101
 
                                                   "audio/x-mp3",true);
102
 
 
103
 
  if(play.isNull()) {
104
 
    cerr << "Can't create PlayObject" << endl;
105
 
    exit(0);
106
 
  }
107
 
  connect(fileInputStream,"outdata", play,"indata");
108
 
  fileInputStream.start();
109
 
  play.play();
110
 
  while(!fileInputStream.eof()) {
111
 
    d->ioManager()->processOneEvent(false);
112
 
  }
113
 
 
114
 
 
115
 
 
116
 
  /*
117
 
 
118
 
 
119
 
 
120
 
  KURL file(argv[optind]);
121
 
 
122
 
  cout << "1"<<endl;
123
 
  Arts::Dispatcher *dispatcher = new Arts::Dispatcher();
124
 
  cout << "2"<<endl;
125
 
 
126
 
  Arts::SoundServerV2 server;
127
 
  cout << "3"<<endl;
128
 
  server = Arts::Reference("global:Arts_SoundServerV2");
129
 
  cout << "4"<<endl;
130
 
  
131
 
  if(server.isNull()) {
132
 
    cerr << "Can't connect to sound server2" << endl;
133
 
    exit(0);
134
 
  }
135
 
  cout << "5"<<endl;
136
 
 
137
 
  KPlayObject *playobj = new KPlayObject();
138
 
  cout << "6"<<endl;
139
 
  playobj->setObject(Arts::PlayObject::null());
140
 
  cout << "7"<<endl;
141
 
  
142
 
  KPlayObjectFactory factory(server);
143
 
  cout << "8"<<endl;
144
 
  playobj = factory.createPlayObject(file, true);
145
 
  cout << "9"<<endl;
146
 
  
147
 
  Arts::PlayObject po=playobj->object();
148
 
 
149
 
  if(po.isNull()) {
150
 
    cerr << "Cannot create playobject" << endl;
151
 
    exit(0);
152
 
  }
153
 
  playobj->play();
154
 
  */
155
 
}
156