void VlcMediaWidget::play(const MediaSource &source) { addPendingUpdates(PlaybackStatus | DvdMenu); QByteArray url = source.getUrl().toEncoded(); playingDvd = false; switch (source.getType()) { case MediaSource::Url: if (url.endsWith(".iso")) { playingDvd = true; } break; case MediaSource::AudioCd: if (url.size() >= 7) { url.replace(0, 4, "cdda"); } else { url = "cdda://"; } break; case MediaSource::VideoCd: if (url.size() >= 7) { url.replace(0, 4, "vcd"); } else { url = "vcd://"; } break; case MediaSource::Dvd: if (url.size() >= 7) { url.replace(0, 4, "dvd"); } else { url = "dvd://"; } playingDvd = true; break; case MediaSource::Dvb: break; } libvlc_media_t *vlcMedia = libvlc_media_new_location(vlcInstance, url.constData()); if (vlcMedia == NULL) { libvlc_media_player_stop(vlcMediaPlayer); Log("VlcMediaWidget::play: cannot create media") << source.getUrl().url(); return; } libvlc_event_manager_t *eventManager = libvlc_media_event_manager(vlcMedia); libvlc_event_e eventTypes[] = { libvlc_MediaMetaChanged }; for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) { if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHandler, this) != 0) { Log("VlcMediaWidget::play: cannot attach event handler") << eventTypes[i]; } } libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia); libvlc_media_release(vlcMedia); // FIXME! // if (source.subtitleUrl.isValid()) { // if (libvlc_video_set_subtitle_file(vlcMediaPlayer, // source.subtitleUrl.toEncoded().constData()) == 0) { // Log("VlcMediaWidget::play: cannot set subtitle file") << // source.subtitleUrl.prettyUrl(); // } // } if (libvlc_media_player_play(vlcMediaPlayer) != 0) { Log("VlcMediaWidget::play: cannot play media") << source.getUrl().url(); } }
void MPlayerMediaWidget::play(const MediaSource &source) { resetState(); QByteArray url = source.getUrl().toEncoded(); switch (source.getType()) { case MediaSource::Url: if (url.endsWith(".iso")) { // FIXME use dvd://, dvdnav:// ? updateDvdMenu(true); } if (source.getUrl().isLocalFile()) { // mplayer can't deal with urls like "file:///tmp/te%20st.m2t" url = QFile::encodeName(source.getUrl().toLocalFile()); url.replace(' ', "\\ "); } break; case MediaSource::AudioCd: if (url.size() >= 7) { // e.g. cdda:////dev/sr0 url.replace(0, 5, "cdda:/"); } else { url = "cdda://"; } break; case MediaSource::VideoCd: if (url.size() >= 7) { // e.g. vcd:////dev/sr0 url.replace(0, 5, "vcd:/"); } else { url = "vcd://"; } break; case MediaSource::Dvd: if (url.size() >= 7) { // e.g. dvdnav:////dev/sr0 url.replace(0, 5, "dvdnav:/"); } else { url = "dvdnav://"; } updateDvdMenu(true); break; case MediaSource::Dvb: if (source.getUrl().isLocalFile()) { // mplayer can't deal with urls like "file:///tmp/te%20st.m2t" url = QFile::encodeName(source.getUrl().toLocalFile()); url.replace(' ', "\\ "); } break; } updatePlaybackStatus(MediaWidget::Playing); updateSeekable(true); process.write("loadfile " + url + '\n'); process.write("pausing_keep_force get_property path\n"); sendCommand(SetDeinterlacing); sendCommand(SetVolume); timerId = startTimer(500); }