Developing A Streaming Server For Android

后端 未结 3 895
南方客
南方客 2020-12-15 15:21

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.

相关标签:
3条回答
  • 2020-12-15 15:38

    I'm not sure what your specific needs are, but for static files you might try combining Amazon S3 and CloudFront, which I believe supports RTSP.

    0 讨论(0)
  • 2020-12-15 15:41

    Developing a RTSP streaming server with Netty is fairly straight forward task and doesn't take much of time. I myself have written it and it worked like a charm. You could look at the sample implementations of some other servers using Netty framework to get started.

    0 讨论(0)
  • 2020-12-15 15:48

    OK, simple as this to stream using HTTP.

    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).

    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;
        }
    }
    

    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.

    0 讨论(0)
提交回复
热议问题