开发流媒体服务器为Android [英] Developing A Streaming Server For Android

查看:105
本文介绍了开发流媒体服务器为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个AV流媒体服务器使用与Android手机的客户端。这立刻使我上制约了开发使用RTSP服务器。我精通Java编程,并发现了Netty(Java NIO)可以用来填补另有大量缺口Java媒体框架此协议。我打了与它周围并没有任何真正的成功。我知道LIVE555,但我在紧张的日程安排,并不真的要开始用C乱搞++,因为我知道得很少的课题。我一直停留在这个问题上几个星期,并没有任何真正显示它。因为有Android市场上众多的专有应用程序流式传输到Android必须是可行的。可能有人谁拥有的经验和知识,在这个问题上,请让我知道是否有实现,只是流的MP4或.3gp使用和MP3播放与Android的使用,而无需使用LIVE555库的RTSP AV媒体服务器的简单方法。如果不是我将不得不赶紧起床,以加快对C ++。先感谢您。

I am trying to develop a Streaming AV Media Server for use with an Android handset as the client. This instantly puts a constraint on me to develop a server that uses RTSP. I am versed in Java programming and have found that Netty (Java NIO) can be used to fill in the otherwise massive gap in the Java Media Framework for this protocol. I have played around with it and have had no real success. I know about live555 but I’m on a tight schedule and don't really want to start messing around with C++ as I know very little on the subject. I have been stuck on this problem for many weeks and have nothing really to show for it. Streaming to android must be possible as there are numerous proprietary apps on the Android market. Could someone who has experience and knowledge on this subject please let me know if there is a simple way to implement an RTSP AV media server that just streams .mp4 or .3gp and .mp3 for use with android without using the live555 libraries. If not I will just have to quickly get up to speed on C++. Thank you in advance.

推荐答案

OK,简单的,因为这要使用HTTP流。

OK, simple as this to stream using HTTP.

我创建在WinXP名为音乐与IIS虚拟文件夹,并把它指向含有MP3文件的文件夹。这是流文件(名称硬codeD)所需的完整的活动。

I created a virtual folder called 'Music' with IIS on WinXP and pointed it at a folder containing mp3 files. This is the complete Activity needed to stream a file (name hard-coded).

顺便说一句,这就是所谓的SimpleNetRadio我最初开始Shoutcast的玩弄流。

BTW, it's called SimpleNetRadio as I originally started playing around with Shoutcast streams.

package com.mycompany.SimpleNetRadio;

import android.app.Activity;
import android.media.AsyncPlayer;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;

public class SimpleNetRadio extends Activity
{
    private AsyncPlayer ap = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected void onStart() {
        super.onStart();
        ap = (AsyncPlayer) getLastNonConfigurationInstance();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (ap != null)
            ap.stop();
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (ap == null) {
            ap = new AsyncPlayer("Simple Player");
            ap.play(this, Uri.parse("http://192.168.1.1/Music/02%20-%20Don't%20Stop%20Believin'.mp3"), true, AudioManager.STREAM_MUSIC);
        }
    }

    @Override
    public Object onRetainNonConfigurationInstance() {
        return ap;
    }
}

您也应该能够做到这一点与MediaPlayer的多一点code - 它会处理错误情况更好,也不会要求更多的工作。

You should also be able to do this with MediaPlayer with a bit more code - it would handle error conditions better and wouldn't require much more work.

这篇关于开发流媒体服务器为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆