2013-03-21 123 views
0

我沒有想到我的實現,現在我卡住了。我使用IIS 7.5,URL Rewrite 2.0和Jplayer。IIS 7.5 URL重定向直接鏈接到媒體頁面

我目前的實施是,我有用戶上傳音頻文件到我的服務器。要收聽這些音頻文件,用戶可以直接鏈接到在瀏覽器中播放或通過應用媒體播放器中的Android/iOS進行播放。

現在我已經創建了一個登錄頁面,我希望將那些直接鏈接到音頻文件的用戶重定向到。着陸頁正在使用Jplayer。

問題是我必須使用直接鏈接到音頻文件才能讓jplayer播放它。由於我正在重定向直接鏈接,因此無法加載媒體網址。

這也成爲一個問題,因爲我的Android和iOS應用程序直接鏈接到.mp3以便在他們的AV播放器中播放文件。有沒有辦法解決?有更好的實施嗎?不知道該怎麼做。

Jplayer:

 $("#jquery_jplayer_1").jPlayer({ 
    ready: function (event) { 
     $(this).jPlayer("setMedia", { 
      mp3: "http://192.168.0.28/flows/t/test/test1334187052069.mp3" 
     }).jPlayer("play"); // auto play; 
    }, 
    swfPath: "js", 
    supplied: "mp3", 
    errorAlerts: true, 
    warningAlerts: true, 
    wmode: "window" 
}); 

IIS 7.5的重定向規則:

<rewrite> 
    <rules> 
     <rule name="FlowURLs"> 
      <match url="^flows/[_0-9a-zA-Z-]+/[_0-9a-zA-Z-]+/([._0-9a-zA-Z-]+)" /> 
      <action type="Redirect" redirectType="Found" url="music.html?flow={R:1}" /> 
     </rule> 
    </rules> 
</rewrite> 

回答

0

一種可能的解決辦法可能是檢查HTTP接受頭,看看它是否是一個瀏覽器期待加載頁面。如果是這樣,那麼你重定向到你的球員登陸頁面。否則,請保持原樣並讓它直接加載音頻文件。

你可以用一個有條件的檢查接受頭:

<rewrite> 
    <rules> 
     <rule name="FlowURLs"> 
      <match url="^flows/[_0-9a-zA-Z-]+/[_0-9a-zA-Z-]+/([._0-9a-zA-Z-]+)" /> 
      <conditions> 
       <add input="{HTTP_ACCEPT}" pattern="text/html" /> 
      </conditions> 
      <action type="Redirect" redirectType="Found" url="music.html?flow={R:1}" /> 
     </rule> 
    </rules> 
</rewrite> 
+0

你好,我忘了,我改變了music.html文件到PHP。我仍然可以使用該文件類型的HTTP_ACCEPT模式嗎? – nawlrus 2013-03-25 13:54:09

+0

是的,只需簡單地用'music.php'替換'music.html'即可。 – 2013-03-26 11:49:29