1
Vala에서 playbin으로 scaletempo를 사용하는 데 문제가 있습니다. playbin을 만든 다음 기본 오디오 싱크를 교체하는 추가 플러그인을 저장할 빈을 만들었습니다. 아래 예제는 pyTranscribe에서 가져 와서 Vala로 변환했지만 Element.link_many는 오류의 원인이며 그 이유는 확실하지 않습니다.Vala를 사용하여 재생 빈에 Scaletempo 추가
나는 올바른 방향으로 가고 있습니까? 아무도 다른 제안이 있습니까?
내가 정적 모든 것을 만드는 동일한 코드를 사용하여 시도하고 아래 같은 결과/오류가 발생/* SoundPlayerBackend.vala */
/* Modified code from Damien Radtke's site. http://damienradtke.org/ */
using Gst;
public class SoundPlayerBackend {
//Constants
const double PLAYBACK_RATE_MODIFIER = 2.0;
const int SEEK_SECONDS = 10;
// Method delegates for notifying SoundPlayer about certain events
protected delegate void NotifyEos();
protected delegate void NotifyError(string message);
// Pointer to our EOS delegate
protected NotifyEos on_eos;
// Pointer to our Error delegate
protected NotifyError on_error;
public static void main(string[] args){
var soundplayer = new SoundPlayerBackend();
Gst.init(ref args);
soundplayer.setUri("file:///home/codenomad/Desktop/player-project/hurricane.mp3");
soundplayer.play();
string stop = stdin.read_line();
while (stop != "stop") {
if (stop == "pause") { soundplayer.pause(); }
else if (stop == "play") { soundplayer.play(); }
stop = stdin.read_line();
}
}
// Read-only reference to the current sound object
public dynamic Element sound { get; private set; }
// Read-only "is playing" property
public bool is_playing { get; private set; default = false; }
// Read-only "rate" property
public double rate { get; private set; default = 1; }
public void setUri(string uri) {
// Make sure any existing allocated resources are freed
if (sound != null)
sound.set_state(Gst.State.NULL);
sound = ElementFactory.make("playbin2", "playbin");
sound.uri = uri;
var audiobin = new Bin("audioline");
var scaletempo = ElementFactory.make("scaletempo", "scaletempo");
var convert = ElementFactory.make("audioconvert", "convert");
var resample = ElementFactory.make("audioresample", "resample");
var audiosink = ElementFactory.make("autoaudiosink", "audiosink");
audiobin.add_many(scaletempo, convert, resample, audiosink);
//edited based on comment below
//Element.link_many(scaletempo, convert, resample, audiosink);
scaletempo.link_many(convert, resample, audiosink);
var pad = scaletempo.get_pad("sink");
audiobin.add_pad(new GhostPad("sink", pad));
sound.set_property("audio-sink", audiobin);
sound.get_bus().add_watch(on_event);
}
// Play the sound
public void play() {
sound.set_state(State.PLAYING);
print("Playing\n");
is_playing = true;
}
// Pause it
public void pause() {
sound.set_state(State.PAUSED);
is_playing = false;
print("Paused\n");
}
// Event bus, listens for events and responds accordingly
protected bool on_event(Gst.Bus bus, Message message) {
switch (message.type) {
case MessageType.ERROR:
GLib.Error err;
string debug;
sound.set_state(Gst.State.NULL);
is_playing = false;
message.parse_error(out err, out debug);
on_error(err.message);
break;
case MessageType.EOS:
sound.set_state(Gst.State.READY);
is_playing = false;
on_eos();
break;
default:
break;
}
return true;
}
}
: 사전에
SoundPlayerBackend.vala:121.9-121.67: error: Access to instance member `Gst.Element.link_many' denied
Element.link_many(scaletempo, convert, resample, audiosink);
감사합니다!
감사를 읽어야합니다! 나는 사운드 출력을하지 않았다, 변경을했고, 나 또한 접수 : (SoundPlayerBackend : 18163) : 입심-G 객체-CRITICAL ** : g_object_ref : 주장'G_IS_OBJECT는 (객체) '실패 (SoundPlayerBackend : 18163) :있는 GStreamer-CRITICAL ** : gst_element_set_state : 주장'GST_IS_ELEMENT은 (요소) ' (SoundPlayerBackend 실패 : 18,163 일) :있는 GStreamer-CRITICAL ** : gst_element_set_state : 주장'GST_IS_ELEMENT (요소)'그것은 하드 가지의 – Ray
실패 그 코드가 어떤 코드인지를 모른 채 경고 메시지를 내 보냅니다. – ptomato
죄송합니다. 나머지 소스를 추가했습니다. 아직 머리를 긁적니다. – Ray