मैंने एक स्क्रिप्ट एक साथ रखी जो फ्लाई पर एमपी 3 फ़ाइल की 30 सेकंड क्लिप आउटपुट करता है। यदि आप फ़ाइल को सहेजना चाहते हैं, तो क्लास/लाइब्रेरी का उपयोग करने वाले अन्य विकल्पों में से एक शायद सबसे अच्छा होगा। लेकिन, अगर आप पूर्वावलोकन को खेलना/डाउनलोड करना चाहते हैं, तो फ्लाई पर बेहतर हो सकता है। यह निश्चित रूप से आपको हार्ड ड्राइव स्थान बचाएगा।
इसे http://www.stephenwalcher.com/2013/06/17/how-to-extract-and-play-part-of-an-mp3-in-php/ पर देखें।
यहां कोड है, लेकिन मेरे ब्लॉग पर एक गहन स्पष्टीकरण मिल सकता है।
$getID3 = new getID3();
$id3_info = $getID3->analyze($filename);
list($t_min, $t_sec) = explode(':', $id3_info['playtime_string']);
$time = ($t_min * 60) + $t_sec;
$preview = $time/30; // Preview time of 30 seconds
$handle = fopen($filename, 'r');
$content = fread($handle, filesize($filename));
$length = strlen($content);
if (!$session->IsLoggedIn()) {
$length = round(strlen($content)/$preview);
$content = substr($content, $length/3 /* Start extraction ~10 seconds in */, $length);
}
header("Content-Type: {$id3_info['mime_type']}");
header("Content-Length: {$length}");
print $content;
स्रोत
2012-01-17 19:51:27
मैं जानता हूँ कि don'y अगर कुछ getID3 lib में बदल गया था या यह 'आपके कोड में एक बग: id3_info सरणी में कोई लंबाई तत्व नहीं है। यह playtime_string होना चाहिए। – latata
लिंक रास्ते से तोड़ दिया गया है। –
लिंक फिक्स्ड। अब जाने के लिए अच्छा होना चाहिए। –