/    Sign up×
Community /Pin to ProfileBookmark

streaming a music .rm file using php

Hi, I have this problem where I want the user of my webpage to click on this link that he cant either listen to the song or download it..i have the songs already stored and their directories stored in the Database, but the thing is that i dont know how i can make a ‘listen’ link that will automatically open in RealPlayer or any music player on the user’s PC..so if anyone knows how i could do that, I would appreciate the help..

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@hastxAug 04.2007 — There are 3 methods I can think of:

1. Use a "stub" file or a (playlist file), this is nothing more than a simple text file that you name with a ".ram" extension for reaplayer, or ".m3u" for the users default mp3 player. the file only needs to contain the fully qualified URL to the audio file. When the link is clicked on the browser hands the plalylist file off to the appropritate app for processing.

  • 2. Use javascript to create an embedded media player, or in this example, open a popup window.
    [CODE]
    function PlayerOpen(soundfiledesc,soundfilepath) {
    PlayWin = window.open('','','width=550,height=150,top=25,left=250,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus();

    var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE><LINK rel='stylesheet' type='text/css' name='style1' href='/styles/media_player.css'></HEAD><BODY bgcolor='#ffffff'><center>";
    winContent += "<div style='font-size:11px; font-weight:bold; font-family:Verdana,sans-serif;line-height:1.5'>" + soundfiledesc + "</div>";

    winContent += "<OBJECT width='300' height='42'>";
    winContent += "<param name='SRC' value='" + soundfilepath + "'>";
    winContent += "<param name='AUTOPLAY' VALUE='true'>";
    winContent += "<param name='CONTROLLER' VALUE='true'>";
    winContent += "<param name='BGCOLOR' VALUE='#FF9900'>";
    winContent += "<EMBED TYPE='application/x-mplayer2' pluginspage='http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&' SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='375' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#e0e0e0'></EMBED>";
    winContent += "</OBJECT>";

    winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='" + soundfilepath +"'>Right-Click to Download</a></p>";
    winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onclick='javascript:window.close();'></DIV></FORM>";
    winContent += "</center></BODY></HTML>";

    PlayWin.document.write(winContent);

    }
    [/CODE]

    Your button to call this function would contain:
    [CODE]
    <a href="javascript:void(PlayerOpen('music/Song.wma', 'music/Song.wma'));">Play</a>
    [/CODE]

  • 3. Use a flash player such as http://musicplayer.sourceforge.net/


  • I have used all these solutions for various purposes in the past.

    The first method can be done without knowing any programming. The second method works well, but can run into cross-platform issues

    The 3rd option is by far the best for you purposes, and comes closest to true "streaming". Flash handles audio files very well, and will give the least download/ buffering time of the methods listed here. It is also the most universal.
    Copy linkTweet thisAlerts:
    @mazazinoauthorAug 04.2007 — ok i tried the first one and it worked perfectly well..thanks?
    ×

    Success!

    Help @mazazino spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...