dpruwm6206 2011-12-15 20:41
浏览 84

如何使用HTML5,Jplayer和mysql跟踪播放列表中的歌曲播放?

I am building a custom based player which will have access to 3 play lists. The client selects the playlist they want to hear. At the end of the day I need someway of counting how many times each song on that playlist was listened to. Can this be done in HTML5 or do I need to do this in php and MySql. This has to work for both iOS, Ipad,as well as windows and android.

  • 写回答

1条回答 默认 最新

  • dongshuao2309 2011-12-15 20:48
    关注

    I've done something like this before, and the solution I came up with was having the MP3 files accessed via a PHP file, which registers the request in a database and then fetches the file and serves it (adding headers so the browser recognizes it as an MP3). Something like:

    //track the file after you've confirmed it's a valid request (filename passed in URL as

    ?mp3=[mp3 filename]
    $logged = track_this($_GET['mp3']); //some tracking function
    
    //now spit it out...
    
    $file_name = "song_name.mp3";
    $file = '/path/to/files/'.$_GET['mp3'].'.mp3';
    
    $mm_type="application/octet-stream";
    
    header("Cache-Control: public, must-revalidate");
    header("Pragma: hack"); 
    header("Content-Type: " . $mm_type);
    header("Content-Length: " .(string)(filesize($file)) );
    header('Content-Disposition: attachment; filename="'.$file_name.'"');
    header("Content-Transfer-Encoding: binary
    ");
    
    print file_get_contents($file);
    

    it works pretty well, though you can't track whether they stopped the track part way through (so it's pretty simple metrics)

    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接