Exemplo n.º 1
0
void BbMediaPlayerControl::setVolumeInternal(int newVolume)
{
    if (!m_context)
        return;

    newVolume = qBound(0, newVolume, 100);
    if (m_audioId != -1) {
        strm_dict_t * dict = strm_dict_new();
        dict = strm_dict_set(dict, "volume", QString::number(newVolume).toAscii());
        if (mmr_output_parameters(m_context, m_audioId, dict) != 0)
            emitMmError("mmr_output_parameters: Setting volume failed");
    }
}
Exemplo n.º 2
0
	void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
	{
		if (0 != strcmp(s_currentBackgroundStr.c_str(), pszFilePath))
		{
			stopBackgroundMusic(true);
		}
		else
		{
			if (s_playStatus == PAUSED)
				resumeBackgroundMusic();
			else
				rewindBackgroundMusic();
		}

		if (!s_isBackgroundInitialized)
			preloadBackgroundMusic(pszFilePath);

		if (bLoop)
		{
			// set it up to loop
			strm_dict_t *dictionary = strm_dict_new();
			s_repeatDictionary = strm_dict_set(dictionary, "repeat", "all");

    		if (mmr_input_parameters(s_mmrContext, s_repeatDictionary) != 0)
    		{
    			mmrerror(s_mmrContext, "input parameters (loop)");
    			return;
    		}
		}

		if (s_hasMMRError || !s_mmrContext)
			return;

		if (mmr_play(s_mmrContext) < 0)
		{
			mmrerror(s_mmrContext, "mmr_play");
			s_hasMMRError = true;
		}

		if (!s_hasMMRError)
			s_playStatus = PLAYING;
	}
Exemplo n.º 3
0
    static void setBackgroundVolume(float volume)
    {
    	if (!s_isBackgroundInitialized)
    	{
    		return;
    	}
		char volume_str[128];

		// set it up the background volume
		strm_dict_t *dictionary = strm_dict_new();

		sprintf(volume_str, "%d", (int)(volume * 100) );
		s_volumeDictionary = strm_dict_set(dictionary, "volume", volume_str);

		if (mmr_output_parameters(s_mmrContext, s_audioOid, s_volumeDictionary) != 0)
		{
			mmrerror(s_mmrContext, "output parameters");
			return;
		}
    }
Exemplo n.º 4
0
int ZaMp3::playloop(const char * url)
{
	const char *mmrname = NULL;
	const char *ctxtname = "testplayer";
	const char *audioout = NULL;
	const char *inputtype = "autolist";
	//int     final_return_code = EXIT_FAILURE;
	mode_t mode = S_IRUSR | S_IXUSR;
	int audio_oid; // output ID
	strm_dict_t *aoparams = NULL; // output parameters

	mmr_connection_t *connection;
	mmr_context_t *ctxt;

	audioout = DEFAULT_AUDIO_OUT;

	strm_dict_t *aiparams = strm_dict_new();
	aiparams = strm_dict_set(aiparams, "repeat", "all");


	getcwd(cwd, PATH_MAX);
	rc = snprintf(inputurl, PATH_MAX, "file://%s%s", cwd, url);

	if ( ( connection = mmr_connect( mmrname ) ) == NULL ) {
		perror( "mmr_connect" );
	} else if ( ( ctxt = mmr_context_create( connection, ctxtname, 0, mode ) ) == NULL ) {
		perror( ctxtname );
	} else if ( audioout && ( audio_oid = mmr_output_attach( ctxt, audioout, "audio" ) ) < 0 ) {
		mmrerror( ctxt, audioout );
	} else if ( aoparams && mmr_output_parameters( ctxt, audio_oid, aoparams ) ) {
		mmrerror( ctxt, "output parameters (audio)" );
	} else if ( mmr_input_attach( ctxt, inputurl, inputtype ) < 0 ) {
		mmrerror( ctxt, inputurl );
    } else if ( aiparams && mmr_input_parameters( ctxt, aiparams ) ) {  // NEW
    	mmrerror( ctxt, "input parameters (audio)" );  // NEW
    } else if ( mmr_play( ctxt ) < 0 ) {
		mmrerror( ctxt, "mmr_play" );
	}
	return 0;
}
Exemplo n.º 5
0
/* 
 * we know the video has a resolution of 640x480 so it has an aspect ratio of
 * of approximately 1.33.  Based on these facts, we can show the video as large
 * as possible without changing the aspect ratio. 
 */ 
strm_dict_t* calculate_rect(int width, int height) {
    const int image_width = 640;
    const int image_height = 480;
    const float image_aspect = (float)image_width / (float)image_height;
    const float aspect_tolerance = 0.1;

    char buffer[16];
    strm_dict_t *dict = strm_dict_new();

    if (NULL == dict) {
        return NULL;
    }

    //fullscreen is the default.
    dict = strm_dict_set(dict, "video_dest_x", "0");
    if (NULL == dict)
        goto fail;
    dict = strm_dict_set(dict, "video_dest_y", "0");
    if (NULL == dict)
        goto fail;
    dict = strm_dict_set(dict, "video_dest_w", itoa(width, buffer, 10));
    if (NULL == dict)
        goto fail; 
    dict = strm_dict_set(dict, "video_dest_h", itoa(height, buffer, 10));
    if (NULL == dict)
        goto fail;

    float screen_aspect = (float)width/(float)height;
    if (fabs(screen_aspect - image_aspect) < aspect_tolerance) {
        //if the screen is at almost the same aspect as the video, just
        //do full screen.  Nothing to do here.  Fall through and return 
        //full screen.
    } else if (screen_aspect < image_aspect) {
        /* The screen is too tall.  We need to centre top to bottom, set the 
         * width the same as the screen's while maintaining the same aspect 
         * ratio.
         */ 
        dict = strm_dict_set(dict, "video_dest_y", itoa((height - image_height) / 2, buffer, 10));
        if (NULL == dict)
            goto fail;

        height = width / image_aspect;

        dict = strm_dict_set(dict, "video_dest_h", itoa(height, buffer, 10));
        if (NULL == dict)
            goto fail;
    } else {
        /* The screen is too wide.  We need to centre left to right, set the 
         * height the same as the screen's while maintaining the same aspect 
         * ratio.
         */
        dict = strm_dict_set(dict, "video_dest_x", itoa((width - image_width) / 2, buffer, 10));
        if (NULL == dict)
            goto fail;

        width = height * image_aspect;

        dict = strm_dict_set(dict, "video_dest_w", itoa(width, buffer, 10));
        if (NULL == dict)
            goto fail;
    }

    return dict;

fail:
    strm_dict_destroy(dict);
    return NULL;
}