ziedinjsh Posted August 7, 2012 Report Share Posted August 7, 2012 (edited) Besī.. esmu nogooglējies līks bet nevaru atrast ejošu preg_match funkciju kas souncloud linku pārvērš playerī.. varbūt kāds māk uztaisīt? piem šāds ir links ko iepostē:http://soundcloud.co...kmylife/untrust un šāds ir playera kods: <iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F55492490&show_artwork=true"></iframe> Šitā neiet: $matches = array( '#(?:https?://).soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)#siU' ); $replacements = array( '<object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=$1&g=bb"></param><param'>http://player.soundcloud.com/player.swf?url=$1&g=bb"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=$1&g=bb" type="application/x-shockwave-flash" width="100%"></embed></object> <a href="$1">$1</a>' ); Edited August 7, 2012 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
rpr Posted August 8, 2012 Report Share Posted August 8, 2012 tur ar regexp nav nekāds sakars. no iekopētā linkasatura jāizparsē track id un tad tu vari to html uzģenerēt. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 linkā nav track id, bet gan http://soundcloud.com/izpildītājs/dziesmas-nosaukums vai tad šis (#(?:https?://).soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)#siU) nepaņem izpildītāju/dziesmas-nosaukums ?? Quote Link to comment Share on other sites More sharing options...
rpr Posted August 8, 2012 Report Share Posted August 8, 2012 nu pieņemsim, ka paņem nosaukumu, izpildītāju, bet kur tu to tālāk bāzīsi? embedojamajā kodā to nevajag (es par to iframe runāju). jebkurā gadījumā regexp pārmudrīts soundcloud\.com/(.+) Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 tā, es neiebraucu, kā tad man jāizskatās ir šim: <?php $text = 'http://soundcloud.com/fuckmylife/untrust'; function media_check($status_text) { $matches = array( '#(?:https?://).soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)#siU' ); $replacements = array( '<object height="81" width="100%"> <param name="movie" value="$1api.soundcloud.com%2Ftracks%2F55492490"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="https://player.soundcloud.com/player.swf?url=$1api.soundcloud.com%2Ftracks%2F55492490" type="application/x-shockwave-flash" width="100%"></embed> </object> <span><a href="$1">Untrust</a> by <a href="$1">fuckmylife</a></span> ' ); $status_text = preg_replace($matches, $replacements, $status_text); return $status_text; } echo media_check($text); ?> Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 šādi: %(?:https?://)(?:www\.)?soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)%im <object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=$1&g=bb"></param><param'>http://player.soundcloud.com/player.swf?url=$1&g=bb"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=$1&g=bb" type="application/x-shockwave-flash" width="100%"></embed></object> man parādās plejeris, bet nav iekšā dziesma.. nav pilnīgs links :? Quote Link to comment Share on other sites More sharing options...
Pats Toms Posted August 8, 2012 Report Share Posted August 8, 2012 http://developers.soundcloud.com/docs/api/reference# Tevi interesē oembed. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 nu labi, bet kā man viņu ietaisīt iekš array ? Quote Link to comment Share on other sites More sharing options...
Pats Toms Posted August 8, 2012 Report Share Posted August 8, 2012 (edited) Tu rakstīji, ka tev ir adrese uz dziesmu @sc. Droši vien, ka tu to vari realizēt izmantojot kādu ajax pieprasījumu ar jsonp. Parametros padod url un atpakaļ tev iedos to jsonu, kur viens no parametriem ir "iframe", kas arī ir tas kods, kuru tu gribi. EDIT. ņemu savus vārdus atpakaļ. Drusku muļķības sarakstīju. Viens no variantiem - tu vari izmantot http://oembed.com/ . Edited August 8, 2012 by Pats Toms Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 jā, bet man viņš liekas nesaprotams.. kapēc nevar ar embed izveidot? Quote Link to comment Share on other sites More sharing options...
Pats Toms Posted August 8, 2012 Report Share Posted August 8, 2012 http://jsfiddle.net/ATAJe/9/ Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 8, 2012 Report Share Posted August 8, 2012 Šī būs gara diskusija. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 8, 2012 Author Report Share Posted August 8, 2012 un kā es viņu varu inklūdot savā kodā? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted August 13, 2012 Author Report Share Posted August 13, 2012 <?php function cloud($link){ ?> <head> <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.min.js'></script> <script type='text/javascript'> $(window).load(function(){ var url="<?php echo $link; ?>"; $.ajax({ type: "GET" ,dataType: "json" ,data: { jsonp : "output" ,url: url ,format: "json" ,iframe: "true" } ,url : "http://soundcloud.com/oembed" ,success: function(data) { $('#player').html(data.html); } }); }); </script> </head> <div id="player"></div> <?php } function media_check($status_text){ $matches = array( '/((https?|ftp).*(gif|png|jpg|jpeg))/i', '%<a(.*)(?:href="https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v= ))([\w\-]{10,12})(?:)([\w\-]{0})\b%x', '%(?:https?://)(?:www\.)?soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)%im', ); $replacements = array( '<a href="$1" target="_blank"><img src="$1" style="width:400px;"/></a>', '<iframe style="width:500px;height:300px;border:0;" src="http://www.youtube-nocookie.com/embed/$2"></iframe>', cloud('http://soundcloud.com/$1') ); $status_text = preg_replace($matches, $replacements, $status_text); return $status_text; } ?> Neiet, jo url parādās kā http://soundcloud.com/$1 iekš cloud('') nestrādā $1; Quote Link to comment Share on other sites More sharing options...
waplet Posted August 13, 2012 Report Share Posted August 13, 2012 Oh snap.... Domā, domā :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.