Exemplo n.º 1
0
void YVPlayer::playCurrent() {
    const char *mmrname = NULL;
    const char *ctxtname = "onebible";
    const char *audioout = NULL;
    const char *inputtype = "track";
    char inputurl[PATH_MAX];
    int rc;
    mmr_connection_t *connection = NULL;

    rc = snprintf(inputurl, PATH_MAX, "file://%s/%s", getenv("HOME"), m_t.toLatin1().data());

    mode_t mode = S_IRUSR | S_IXUSR;
    int audio_oid; // output ID
    strm_dict_t *aoparams = NULL; // output parameters

    audioout = DEFAULT_AUDIO_OUT;

    // TODO: Better error reporting
    if ( ( connection = mmr_connect( mmrname ) ) == NULL ) {
        snprintf(msg, MSG_SIZE, "mmr_connect: %s", strerror(errno));
    } else if ( ( m_ctxt = mmr_context_create( connection, ctxtname, 0, mode ) ) == NULL ) {
        snprintf(msg, MSG_SIZE, "%s: %s", ctxtname, strerror(errno));
    } else if ( audioout && ( audio_oid = mmr_output_attach( m_ctxt, audioout, "audio" ) ) < 0 ) {
    } else if ( aoparams && mmr_output_parameters( m_ctxt, audio_oid, aoparams ) ) {
    } else if ( mmr_input_attach( m_ctxt, inputurl, inputtype ) < 0 ) {
    } else if ( mmr_play( m_ctxt ) < 0 ) {
    } else {
    }

    mmrenderer_request_events(ctxtname, 0, 0); // bps
    return;
}
Exemplo n.º 2
0
void BbMediaPlayerControl::openConnection()
{
    m_connection = mmr_connect(NULL);
    if (!m_connection) {
        emitPError("Unable to connect to the multimedia renderer");
        return;
    }

    m_id = idCounter++;
    m_contextName = QString("BbMediaPlayerControl_%1_%2").arg(m_id)
                                                         .arg(QCoreApplication::applicationPid());
    m_context = mmr_context_create(m_connection, m_contextName.toAscii(),
                                   0, S_IRWXU|S_IRWXG|S_IRWXO);
    if (!m_context) {
        emitPError("Unable to create context");
        closeConnection();
        return;
    }

    s_idToPlayerMap.insert(m_id, this);
    m_eventMonitor = mmrenderer_request_events(m_contextName.toAscii(), 0, m_id);
    if (!m_eventMonitor) {
        qBbMediaDebug() << "Unable to request multimedia events";
        emit error(0, "Unable to request multimedia events");
    }
}
void BpsMediaPlayerControl::startMonitoring(int contextId, const QString &contextName)
{
    m_eventMonitor = mmrenderer_request_events(contextName.toLatin1().constData(), 0, contextId);
    if (!m_eventMonitor) {
        qDebug() << "Unable to request multimedia events";
        emit error(0, "Unable to request multimedia events");
    }
}