doujiyan0971 2016-06-16 11:21
浏览 37
已采纳

有没有办法在设备之间同步数据而不保存在服务器上? [关闭]

I want to make my own music player website and app and I want to make it so whenever I add a new song anywhere it will update on the other platform.

How can I do this without actually saving all the songs on a server? I can use a server to pass the data through for syncing but I wanna do it without saving because my host limits my data.

Here's what I thought about but I'm not sure: Maybe every hour or so both types of clients would connect to the server and share differences (although this would be hard if I add new songs both on the website and on the app). Or I could have a manual sync button and just use it on both the phone and the app to sync. Are my ideas practical? And if not is this even possible?

(I can only use PHP with my host and I will use accounts i.e. username and password for the syncing)

  • 写回答

1条回答 默认 最新

  • douyue8191 2016-06-16 12:38
    关注

    So your desired result is for all clients to be synchronized.

    If I had to implement this, I would implement behavior on all my clients that would ask for updates on startup, and push changes on exit. Then on my server, I would create an API that can handle these requests, using a database to store the metadata of these changes (i.e. location of an audio file rather than the entire file). For each change sent to the server, I would keep a datetime for when it was sent, enabling you to incrementally build a change package when a new client asks for updates.

    A client will accept an update (probably a json formatted string containing all the information about downloaded music, currently playing music, etc), after which it will handle the update, meaning it will download the corresponding files or play a certain audio file from a certain point.

    Note that this does not allow you to start a certain song on the one client, and seeing it start on the other client as well. If you want to achieve this, you need to push notifications to the server from the client where you perform a certain action, and use the server to notify other clients of this action through websockets.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记