Hello,

I would like to view items (video, sound) separately.

Could you give me the miracle function that takes care of that.

Here is an example:
( print_r($node->field_video['und'][0]) )

Array
(
    [fid] => 161
    [title] => 
    [data] => 
    [file] => stdClass Object
        (
            [fid] => 161
            [uid] => 1
            [filename] => hardwell-spaceman-drown-the-1
            [uri] => soundcloud://u/hardwell/a/hardwell-spaceman-drown-the-1
            [filemime] => audio/soundcloud
            [filesize] => 0
            [status] => 1
            [timestamp] => 1335785330
            [type] => audio
        )

)

Desired result:
<iframe width="472" height="296" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F44537844&amp;auto_play=false&amp;show_artwork=true&amp;color=e81f4a"></iframe>

or only :

http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftr...

Thank you in advance for your help!

Comments

victoriachan’s picture

Hi Clément,

Sorry about the late reply. One approach you can use to get details for the track is by manually instantiating a file stream wrapper using the file's uri. See example below:

$uri = $node->field_video['und'][0]['file']->uri; // using your example
$wrapper = file_stream_wrapper_get_instance_by_uri($uri); // instantiate by uri
$url = $wrapper->interpolateUrl();
$embed_data = $wrapper->getOEmbed($url); // this will make a drupal_http_request to soundcloud to get info for the track
print($embed_data['html']); // this is the iframe html embed code

Take a look at how this is done in media_soundcloud_preprocess_media_soundcloud_audio() in media_soundcloud/includes/themes/media_soundcloud.theme.inc.

The $embed_data returned will look something like this:

Array
(
    [version] => 1
    [type] => rich
    [provider_name] => SoundCloud
    [provider_url] => http://soundcloud.com
    [height] => 166
    [width] => 100%
    [title] => Hardwell - Spaceman (Drown The Fish Remix) [OUT NOW] by HARDWELL
    [description] => OUT NOW! http://s.beatport.com/KMmufh Hardwell’s Spaceman has been destroying....
    [thumbnail_url] => http://i1.sndcdn.com/artworks-000022387646-2digwj-t500x500.jpg?34f5d10
    [html] => <iframe src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F44537844&amp;show_artwork=true" frameborder="no" height="166" scrolling="no" width="100%"></iframe>
    [author_name] => HARDWELL
    [author_url] => http://soundcloud.com/hardwell
)
13rac1’s picture

Category: task » support
Status: Active » Closed (fixed)

IMO this support request has been sufficiently answered.