GithubHelp home page GithubHelp logo

900secondssdk-android's Introduction

LiveStreamingSDK

Live Streaming Video SDK for Android

LiveStreaming SDK is a video streaming library made for easily add geolocated live streaming into your mobile app. It encapsulates the whole stack of video streaming-related tech involved in live streaming process such as handling device camera, processing video with filters and encoding video chunks with ffmpeg, uploading them to your file storage. Also it has a backend that handles app authorization, stores streams objects and can be requested for fetching available streams.

Some of the features the SDK handles:

  • shooting the video with device camera
  • applying video effects (blur, distrtions, bitmap overlaying over video, etc) on the fly
  • compress video chunks and upload them to a file storage
  • fetching available streams around the geolocation
  • video streams playback

Quick start guide

  1. Intallation
  2. Basic usage
  3. Example application
  4. Other Requirements

Installation and dependencies

For LiveStreaming SDK using needs following:

  • jcenter repository in build.gradle
repositories {
   jcenter()
}
  • include the livestream-sdk dependency:
dependencies {
    // ... other dependencies here.     
    compile 'com.livestream:livestream-sdk:0.2.0'
}

Basic usage

Overview of all basic library features with comments.

Autorizing the app

First of all, you need to register your app with 900Seconds web interface. Registration will require your application ID. Also in order for library to be able to stream video you have to provide it with an access to your file storage. Currently only AWS S3 is supported. You need to register on AWS, get credentials for file storage and use them while registering your app for 900Seconds SDK. In return 900Seconds will give you secret key which you can use for authorizing the app with SDK.

Authorizing itself is very easy and require just one call to Nine00SecondsSDK:

Nine00SecondsSDK.registerAppIDWithSecret(getBaseContext(),
		"yourAppId", 
		"yourSecretKey");

This call should be made on startup. Presumably on your application class but it's really your choice, just make it before your start using the SDK.

For author autorization you should use:

Nine00SecondsSDK.loginWithAuthorId(userId);

userId is unique string. You can generate it randomly or use userId from other API like facebook, twitter etc.

Recording video

LiveStreaming SDK has all camera-related and ffmpeg encoding logic inside already so you don't need to set anything at all. To start preview video feed from the camera just add CameraFragment to your view hierarchy. your_camera_activity_layout.xml may look like:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    <FrameLayout
        android:clickable="false"
        android:id="@+id/cameraViewContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!--
		You can add your design features here like start streaming button etc.
	-->

</RelativeLayout>

and in YourCameraStreamingActivity add:

public class YourCameraStreamingActivity extends Activity {

	private CameraFragment cameraFragment; 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.your_camera_streaming_activity);
		if (savedInstanceState == null) {
			cameraFragment = CameraFragment.getInstance();
			cameraFragment.setQuality(HLSQualityPreset.PRESET_640x480); //set your quality

			cameraFragment.setScalePreviewToFit(true); // Set to true if needs scale preview to fit inside camera fragment
			
			cameraFragment.setStreamingOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // set needed streaming orientation
			
			getFragmentManager().beginTransaction()
			.replace(R.id.cameraViewContainer, cameraFragment)
			.commit();
			
			cameraFragment.setCameraViewListener(this); // optional. start/stop/recording time change events
		}
	}

You can change camera for recording with

cameraFragment.requestCamera(cameraNum);

Or set live filter to be applied over stream (both broadcast and preview)

cameraFragment.applyVideoFilter(Filters.FILTER_BLACK_WHITE); // or other filter from  com.livestreamsdk.streaming.Filters class

To start streaming you need just another one call:

cameraFragment.startRecording();

This call will create stream object on the backend and start writing and uploading video chunks to the file storage. Also it will start observing your location as every stream in our SDK obliged to have a location. In order to keep user's privacy coordinates are taken with precision up to only 100 meters.

To stop streaming and preview just call:

cameraFragment.stopRecording();

Most of preview and broadcasting calls are asynchronous. Add Nine00SecondsCameraViewListener to know exactly when start/stop methods have finished:

			
cameraFragment.setCameraViewListener(new Nine00SecondsCameraViewListener() {
	
	@Override
	public void onStartRecord(String streamId) {
	}
	
	@Override
	public void onStopRecord(String streamId) {
		.....
		finish(); // for example
	}
	
	@Override
	public void onRecordingTimeChange(long recordingTime) {
		String ms = String.format("%02d:%02d", 
				TimeUnit.MILLISECONDS.toMinutes(recordingTime) % TimeUnit.HOURS.toMinutes(1),
				TimeUnit.MILLISECONDS.toSeconds(recordingTime) % TimeUnit.MINUTES.toSeconds(1));
		
		if (lastShowedTime.equals(ms))
			return;
		
		lastShowedTime = ms;
		Log.i("TEST_APP", "Recording time is:" + ms);
	}
});

Fetching live streams

All the streams made by your application with the SDK can be fetched from backend as an object StreamsListData that contains array of StreamData objects. StreamData is a model object which contains information about stream such as it's ID, author ID, when it was started or stopped, how much it was watched through it's lifetime and so on.

There are two main options for fetching streams. The first is to fetch streams with radius around some location point. To perform this fetch you should call

Nine00SecondsSDK.fetchStreamsNearCoordinate(new Nine00SecondsSDK.RequestStreamsListCallback() {

	@Override
	public void onFault(RequestErrorType error) {
	}

	@Override
	public void onComplete(final StreamsListData streamsListData) {
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				updateStreamsList(streamsListData.getStreams()); // for example
				totalBrodcasts.setText(String.valueOf(streamsListData.getTotal())); // for example
			}
		});
	}
}, currentMapLatLNG, -1, -1, currentFilterType);

Fetch will request the backend for list of streams satisfying the parameters. When backend responds the completion will be called. You can set radius to -1 or since to -1 to ignore those parameters, it will return all the streams made by this application.

The second fetch option is to fetch last 30 streams made by specific author.

Nine00SecondsSDK.fetchRecentStreams(new Nine00SecondsSDK.RequestStreamsListCallback() {
	
	@Override
	public void onFault(RequestErrorType error) {
	}
	
	@Override
	public void onComplete(StreamsListData streamsListData) {
		updateStreamsList(streamsListData.getStreams()); // for example
	}
}, userId);

By default any StreamData object has authorID property set to some unique string generated on first app launch. So every stream has an identifier of an application on a particular device it was made with. Passing this identifier to this method will specify which user streams you want to fetch. To fetch streams made by current user you have to pass current application's authorID to this method.

Stream playback

To play any stream you can use any player you want. You can play this URL with VideoView or any other player. LiveStream SDK can evaluate the popularity of each stream. To make this happen the application must to notify the LiveStream backend that someone started watching the stream.

Nine00SecondsSDK.notifyStreamWatched(null, streamId);

For playing stream you must know url for hls stream. You can get this with

String streamUrl = Nine00SecondsSDK.getStreamURL(streamId);
videoView.setVideoPath(path); // for example

Example application

You can get an example application from git repository It contains code example for camera streaming, stream playing, streams list retrieving and other.

Other Requirements

Your app have to require minSdkVersion 18:

android {
....
    defaultConfig {
		.....
        minSdkVersion 18
    }
}

900secondssdk-android's People

Contributors

mr-diestro avatar mrdiestro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

900secondssdk-android's Issues

Problem with Sharing Video URL on Social Networks

I need the user to be able to share the url of the streamed video on social networks before starting the process of streaming. My problem is that I don't know how to get the url of the video before the beginning of streaming, so that I would be able to give it to a player (to get it played) afterwards.

Click on streaming it's crush with following error

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.livestreamsdk.example/com.livestreamsdk.example.CameraStreamingActivity}: java.lang.IllegalArgumentException: Access key cannot be null.

Please give me proper solution as soon as possible

change directory name

I want change directory name 'nine900', How can I do this?

D/EYEYE: directory ready: /storage/emulated/0/nine900/ts
I/EYEYE: Created muxer for output: /storage/emulated/0/nine900/ts/adf26bfc-aadf-463b-9425-77b20ffd32ae/stream.m3u8

Getting Error

Hi. Why sometimes when I want to get the list of my streams, I just receive the error written below?

04-07 22:48:07.995 23082-23111/com.livestreamsdk.example I/EYEYE: <Backend> GET REQUEST https://api.livestreamsdk.com/stream/recent?appID=__test_app_id COMPLETED 
04-07 22:48:08.040 23082-23111/com.livestreamsdk.example E/EYEYE: <Nine00SecondsSDK> org.json.JSONException: End of input at character 65097 of {
                                                                    "total": 171,
                                                                    "offset": 0,
                                                                    "count": 171,
                                                                    "maxPopularity": 1608,
                                                                    "streams": [
                                                                      {
                                                                        "streamID": "51c73d27-cd0d-40a4-aa37-04762bc4a187",
                                                                        "authorID": "sjac59w26ts3papfj8bymb1rv0i0jojz",
                                                                        "appID": "__test_app_id",
                                                                        "streamType": "",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 2,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T15:34:32.633Z",
                                                                        "updatedAt": "2016-04-07T17:31:41.497Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            51.35810490866575,
                                                                            35.85830293852319
                                                                          ]
                                                                        },
                                                                        "lastSegmentCreatedAt": "2016-04-07T15:35:00.593Z",
                                                                        "stoppedAt": "2016-04-07T15:34:59.234Z",
                                                                        "id": "57067e08a37a30d40318b13c",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "1045232728841691",
                                                                        "streamID": "6B6FFA1D-4FF1-45E9-87EB-2B0B6D4B75F6",
                                                                        "validUntil": "2016-04-08T09:50:35.683Z",
                                                                        "preciseLocation": 0,
                                                                        "popularity": 4,
                                                                        "ratingPoints": 240,
                                                                        "createdAt": "2016-04-07T09:50:25.235Z",
                                                                        "updatedAt": "2016-04-07T15:45:04.216Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            9.764797694540253,
                                                                            47.67509656845965
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/6B6FFA1D-4FF1-45E9-87EB-2B0B6D4B75F6_preview.jpg",
                                                                        "streamType": "landsc",
                                                                        "lastSegmentCreatedAt": "2016-04-07T09:50:48.789Z",
                                                                        "stoppedAt": "2016-04-07T09:50:49.260Z",
                                                                        "id": "57062d61a37a30d40318b126",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "129D6572-3FBD-40A6-A439-D2D8A6D90E89",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 8,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T07:18:38.775Z",
                                                                        "updatedAt": "2016-04-07T15:45:40.873Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73964330196337,
                                                                            30.67586473488633
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/129D6572-3FBD-40A6-A439-D2D8A6D90E89_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T07:22:23.272Z",
                                                                        "id": "570609ceec837d5504a1eac4",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "E81ECDE9-0B07-4FFA-9405-DAF2C6C22DF3",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 3,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T07:00:35.498Z",
                                                                        "updatedAt": "2016-04-07T10:23:55.185Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73955497415812,
                                                                            30.67590144405959
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/E81ECDE9-0B07-4FFA-9405-DAF2C6C22DF3_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T07:04:33.925Z",
                                                                        "id": "57060593a37a30d40318b0ee",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "1173A2E2-1D33-406C-9978-F6F90DF9F06F",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 4,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T06:55:03.820Z",
                                                                        "updatedAt": "2016-04-07T10:23:24.565Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73973193535787,
                                                                            30.6758731477604
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/1173A2E2-1D33-406C-9978-F6F90DF9F06F_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T06:55:48.675Z",
                                                                        "stoppedAt": "2016-04-07T06:55:49.666Z",
                                                                        "id": "57060447a37a30d40318b0e9",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "streamID": "572ff7cc-e189-4f35-b9e4-3c6c48831138",
                                                                        "authorID": "zjett2uqcqa4kfjtgjp7d9s

License Id Request

I tried to email [email protected] to initiate a license id request, but the email was returned as undeliverable. Below is the response I received.

Original Message Details
Created Date: 5/18/2017 4:39:30 PM
Sender Address: [email protected]
Recipient Address: [email protected]
Subject: License Id Request

Error Details
Reported error: 550 5.7.350 Remote server returned message detected as spam -> 550 [email protected] recipient rejected
DSN generated by: BL2PR06MB2131.namprd06.prod.outlook.com
Remote server: bosimpinc12
Message Hops
HOP TIME (UTC) FROM TO WITH RELAY TIME
1 5/18/2017
4:39:30 PM BL2PR06MB2130.namprd06.prod.outlook.com BL2PR06MB2130.namprd06.prod.outlook.com mapi *
2 5/18/2017
4:39:30 PM BL2PR06MB2130.namprd06.prod.outlook.com BL2PR06MB2131.namprd06.prod.outlook.com Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) *
Original Message Headers
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=jacksonsystems.onmicrosoft.com; s=selector1-jacksonsystems-com;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;
bh=VQ9GabUqgSp9cTexAhQXmDKIBUiHNhfO/gjP2iT2BYs=;
b=r1cqQqYXCadsItAQ11QEFdgrOxq9FvXgb3+aTgH1xMSigho31CUGE61Q2gdUZOa/UxQ9PW2ciba0wz4csOkx5ultJgw2G1J5hWHWJvFSQux3ca4ZVOLrN55Ib+K73M7RmovuGf2QJGS+IxrXTtCFDOaKUcd1YTqostRNpwoa32Q=
Received: from BL2PR06MB2130.namprd06.prod.outlook.com (10.167.99.154) by
BL2PR06MB2131.namprd06.prod.outlook.com (10.167.99.155) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id
15.1.1101.14; Thu, 18 May 2017 16:39:30 +0000
Received: from BL2PR06MB2130.namprd06.prod.outlook.com ([10.167.99.154]) by
BL2PR06MB2130.namprd06.prod.outlook.com ([10.167.99.154]) with mapi id
15.01.1101.019; Thu, 18 May 2017 16:39:30 +0000
From: Shaun McCoy [email protected]
To: "[email protected]" [email protected]
Subject: License Id Request
Thread-Topic: License Id Request
Thread-Index: AQHSz/VR8dCSPDUy3U2L2/7+TE2cPA==
Date: Thu, 18 May 2017 16:39:30 +0000
Message-ID: [email protected]
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
authentication-results: livestreamsdk.com; dkim=none (message not signed)
header.d=none;livestreamsdk.com; dmarc=none action=none
header.from=jacksonsystems.com;
x-originating-ip: [50.251.4.220]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1;BL2PR06MB2131;7:XpqJQ4dAQU1M+IkxFsMM2bHaQ88fN4MNSp/EoZ7MQlM915BmJzV0NKl9bIEP77iZZ7WrudJbABbid/TTm0lc4D3aCQ7dgyQYJvEp+hAOR/4ppStGU2Rv+s1sKorYVxXHYZCj9+lxIfVgHgYIxBvFG6guc36/q1cS00iceLRKWo/M8X4o65EV0EtlKpO6NSKVdGg2WohpBrHbLRsvSiCYWn9fvsWvIscUEgHnC2OtkOSe1A7FNQTv0b0m9yrjxSov+1xoIsy+O/140xuPVoTHZdj5GX45fB9u3IKYvNdn/8qGrXAEgo0Vzla6ZdQAt14k89gsI9T5iWMJ+pvpG6hQkg==
x-ms-traffictypediagnostic: BL2PR06MB2131:
x-ms-office365-filtering-correlation-id: 7f7b6129-a7b8-4ec1-31ec-08d49e0c74bd
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081);SRVR:BL2PR06MB2131;
x-microsoft-antispam-prvs: BL2PR06MB21315A786DED768F4A5DD72686E40@BL2PR06MB2131.namprd06.prod.outlook.com
x-exchange-antispam-report-test: UriScan:(116415991822766)(128460861657000)(254730959083279)(86561027422486)(81227570615382)(21748063052155)(81160342030619)(21532816269658)(64217206974132)(91638250987450);
x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(102415395)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(6072148);SRVR:BL2PR06MB2131;BCL:0;PCL:0;RULEID:;SRVR:BL2PR06MB2131;
x-forefront-prvs: 0311124FA9
x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39410400002)(39400400002)(39450400003)(39830400002)(3480700004)(1250700005)(36756003)(8936002)(6116002)(102836003)(6506006)(6486002)(3846002)(77096006)(7736002)(25786009)(38730400002)(110136004)(1730700003)(8676002)(81166006)(53936002)(7066003)(82746002)(2906002)(83716003)(9326002)(86362001)(6916009)(99936001)(3660700001)(33656002)(50986999)(5660300001)(189998001)(3280700002)(122556002)(6436002)(5640700003)(606005)(733005)(478600001)(2501003)(2900100001)(7906003)(2351001)(861006)(66066001)(45080400002)(6512007)(6306002)(54556002)(99286003)(7116003)(236005)(54356999)(54896002)(554374003);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR06MB2131;H:BL2PR06MB2130.namprd06.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en;
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/related;
boundary="004_DCCF179305F64056BFAFF341105149A3jacksonsystemscom";
type="multipart/alternative"
MIME-Version: 1.0
X-OriginatorOrg: jacksonsystems.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2017 16:39:30.0966
(UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a67a2406-46c5-4748-ad5f-d8f2267a12fe
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR06MB2131

java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference

Hello every one
please help

this the Logcat

` Process: com.example.shibli.luxuryrider, PID: 23959
java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference

    at com.example.shibli.luxuryrider.Home.requestPickupHere(Home.java:338)
    at com.example.shibli.luxuryrider.Home.access$000(Home.java:96)
    at com.example.shibli.luxuryrider.Home$2.onClick(Home.java:217)
    at android.view.View.performClick(View.java:4848)
    at android.view.View$PerformClick.run(View.java:20300)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5682)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)

06-15 04:25:03.168 23959-24106/com.example.shibli.luxuryrider E/NativeCrypto: ssl=0x7f90eb6700 cert_verify_callback x509_store_ctx=0x7f7b260138 arg=0x0
06-15 04:25:03.168 23959-24106/com.example.shibli.luxuryrider E/NativeCrypto: ssl=0x7f90eb6700 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
`
And this the code

`@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

    mService = Common.getFCMService();

    fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);

    //init storage
    storage = FirebaseStorage.getInstance();
    storageReference = storage.getReference();


    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    View navigationHeaderView = navigationView.getHeaderView(0);
    txtRiderName = navigationHeaderView.findViewById(R.id.txtRiderName);
    txtRiderName.setText(String.format("%s", Common.currentUser.getName()));
    txtStars = navigationHeaderView.findViewById(R.id.txtStars);
    txtStars.setText(String.format("%s", Common.currentUser.getRates()));
    imageAvatar = navigationHeaderView.findViewById(R.id.imageAvatar);

    //Load avatar
    if (Common.currentUser.getAvatarUrl() != null && !TextUtils.isEmpty(Common.currentUser.getAvatarUrl())) {
        Picasso.with(this)
                .load(Common.currentUser.getAvatarUrl())
                .into(imageAvatar);
    }

    //Maps
    mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    //Geo Fire
    ref = FirebaseDatabase.getInstance().getReference("Drivers");
    geoFire = new GeoFire(ref);

    //init View
    imgExpandable = (ImageView)findViewById(R.id.imgExpandable);
    mBottomSheet = BottomSheetRiderFragment.newInstance("Rider bottom sheet");
    imgExpandable.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mBottomSheet.show(getSupportFragmentManager(),mBottomSheet.getTag());

        }
    });

     btnPickupRequest = (Button) findViewById(R.id.btnPickupRequest);
     btnPickupRequest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (!Common.isDriverFound)
               requestPickupHere(FirebaseAuth.getInstance().getCurrentUser().getUid());
            else
                sendRequestToDriver(Common.driverId);
        }
    });

    place_destination = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_destination);
    place_location = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_location);
    typeFilter = new AutocompleteFilter.Builder()
            .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
            .setTypeFilter(3)
            .build();

    //Event
    place_location.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {

            mPlaceLocation = place.getAddress().toString();

            //Remove Old Marker
            mMap.clear();

            //Add Marker at New Location
            mUserMarker = mMap.addMarker(new MarkerOptions().position(place.getLatLng())
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
                    .title("Pickup Here"));
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 15.0f));

        }

        @Override
        public void onError(Status status) {

        }
    });
    place_destination.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            mPlaceDestination = place.getAddress().toString();

            //Add New destination Marker
            mMap.addMarker(new MarkerOptions()
                    .position(place.getLatLng())
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.destination_marker))
                    .title("Destination"));


            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 15.0f));

           // Show information in bottom
            BottomSheetRiderFragment mBottomsheet = BottomSheetRiderFragment.newInstance(mPlaceLocation);
            mBottomsheet.show(getSupportFragmentManager(), mBottomsheet.getTag());
        }

        @Override
        public void onError(Status status) {

        }
    });

    setUpLocation();

    updateFirebaseToken();
}

private void updateFirebaseToken() {
    FirebaseDatabase db = FirebaseDatabase.getInstance();
    DatabaseReference tokens = db.getReference(Common.token_tb1);

    Token token = new Token(FirebaseInstanceId.getInstance().getToken());
    tokens.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
            .setValue(token);

}

private void sendRequestToDriver(String driverId) {
    DatabaseReference tokens = FirebaseDatabase.getInstance().getReference(Common.token_tb1);

    tokens.orderByKey().equalTo(driverId)
            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    for (DataSnapshot postSnapShot : dataSnapshot.getChildren()) {
                        Token token = postSnapShot.getValue(Token.class);

                        //Make raw payload
                        String json_lat_lng = new Gson().toJson(new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()));
                        String riderToken = FirebaseInstanceId.getInstance().getToken();
                        Notification data = new Notification(riderToken, json_lat_lng);
                        Sender content = new Sender(token.getToken(), data);

                        mService.sendMessage(content)
                                .enqueue(new Callback<FCMResponse>() {
                                    @Override
                                    public void onResponse(Call<FCMResponse> call, Response<FCMResponse> response) {
                                        if (response.body().success == 1)
                                            Toast.makeText(Home.this, "Request sent", Toast.LENGTH_SHORT).show();
                                        else
                                            Toast.makeText(Home.this, "Failed", Toast.LENGTH_SHORT).show();
                                    }

                                    @Override
                                    public void onFailure(Call<FCMResponse> call, Throwable t) {
                                        Log.e("ERROR", t.getMessage());

                                    }
                                });
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });
}

private void requestPickupHere(String uid) {
    DatabaseReference dbRequest = FirebaseDatabase.getInstance().getReference(Common.pickup_request_tb1);
    GeoFire mGeoFire = new GeoFire(dbRequest);
    mGeoFire.setLocation(uid, new GeoLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude()));

    if (mUserMarker.isVisible())
        mUserMarker.remove();

    //Add new Marker
    mUserMarker = mMap.addMarker(new MarkerOptions()
            .title("Pickup Here")
            .snippet("")
            .position(new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()))
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
    mUserMarker.showInfoWindow();

    btnPickupRequest.setText("Getting your Driver...");

    findDriver();


}

`

Encountering Error When Trying to Get the List of the Streams

Hi. Why sometimes when I want to get the list of streams, I encounter the problem written below which happens when one wants to parse the json output of your API?

04-07 22:48:07.995 23082-23111/com.livestreamsdk.example I/EYEYE: <Backend> GET REQUEST https://api.livestreamsdk.com/stream/recent?appID=__test_app_id COMPLETED 
04-07 22:48:08.040 23082-23111/com.livestreamsdk.example E/EYEYE: <Nine00SecondsSDK> org.json.JSONException: End of input at character 65097 of {
                                                                    "total": 171,
                                                                    "offset": 0,
                                                                    "count": 171,
                                                                    "maxPopularity": 1608,
                                                                    "streams": [
                                                                      {
                                                                        "streamID": "51c73d27-cd0d-40a4-aa37-04762bc4a187",
                                                                        "authorID": "sjac59w26ts3papfj8bymb1rv0i0jojz",
                                                                        "appID": "__test_app_id",
                                                                        "streamType": "",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 2,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T15:34:32.633Z",
                                                                        "updatedAt": "2016-04-07T17:31:41.497Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            51.35810490866575,
                                                                            35.85830293852319
                                                                          ]
                                                                        },
                                                                        "lastSegmentCreatedAt": "2016-04-07T15:35:00.593Z",
                                                                        "stoppedAt": "2016-04-07T15:34:59.234Z",
                                                                        "id": "57067e08a37a30d40318b13c",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "1045232728841691",
                                                                        "streamID": "6B6FFA1D-4FF1-45E9-87EB-2B0B6D4B75F6",
                                                                        "validUntil": "2016-04-08T09:50:35.683Z",
                                                                        "preciseLocation": 0,
                                                                        "popularity": 4,
                                                                        "ratingPoints": 240,
                                                                        "createdAt": "2016-04-07T09:50:25.235Z",
                                                                        "updatedAt": "2016-04-07T15:45:04.216Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            9.764797694540253,
                                                                            47.67509656845965
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/6B6FFA1D-4FF1-45E9-87EB-2B0B6D4B75F6_preview.jpg",
                                                                        "streamType": "landsc",
                                                                        "lastSegmentCreatedAt": "2016-04-07T09:50:48.789Z",
                                                                        "stoppedAt": "2016-04-07T09:50:49.260Z",
                                                                        "id": "57062d61a37a30d40318b126",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "129D6572-3FBD-40A6-A439-D2D8A6D90E89",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 8,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T07:18:38.775Z",
                                                                        "updatedAt": "2016-04-07T15:45:40.873Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73964330196337,
                                                                            30.67586473488633
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/129D6572-3FBD-40A6-A439-D2D8A6D90E89_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T07:22:23.272Z",
                                                                        "id": "570609ceec837d5504a1eac4",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "E81ECDE9-0B07-4FFA-9405-DAF2C6C22DF3",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 3,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T07:00:35.498Z",
                                                                        "updatedAt": "2016-04-07T10:23:55.185Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73955497415812,
                                                                            30.67590144405959
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/E81ECDE9-0B07-4FFA-9405-DAF2C6C22DF3_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T07:04:33.925Z",
                                                                        "id": "57060593a37a30d40318b0ee",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "appID": "__test_app_id",
                                                                        "authorID": "70EA320D-C521-4C02-A1EE-DA8E9EE15197",
                                                                        "streamID": "1173A2E2-1D33-406C-9978-F6F90DF9F06F",
                                                                        "validUntil": null,
                                                                        "preciseLocation": 1,
                                                                        "popularity": 4,
                                                                        "ratingPoints": 200,
                                                                        "createdAt": "2016-04-07T06:55:03.820Z",
                                                                        "updatedAt": "2016-04-07T10:23:24.565Z",
                                                                        "location": {
                                                                          "type": "Point",
                                                                          "coordinates": [
                                                                            76.73973193535787,
                                                                            30.6758731477604
                                                                          ]
                                                                        },
                                                                        "previewUrl": "http://900seconds.s3-eu-west-1.amazonaws.com/1173A2E2-1D33-406C-9978-F6F90DF9F06F_preview.jpg",
                                                                        "lastSegmentCreatedAt": "2016-04-07T06:55:48.675Z",
                                                                        "stoppedAt": "2016-04-07T06:55:49.666Z",
                                                                        "id": "57060447a37a30d40318b0e9",
                                                                        "isGolden": false
                                                                      },
                                                                      {
                                                                        "streamID": "572ff7cc-e189-4f35-b9e4-3c6c48831138",
                                                                        "authorID": "zjett2uqcqa4kfjtgjp7d9s

NullPointerException - Location & LocationManager - double

hi,
I'm getting a null pointer exception from launch CameraStreamingActivity.
Here is the logcat error output:

 E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
                                                            Process: -, PID: 24769
                                                            java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLongitude()' on a null object reference
                                                                at com.livestreamsdk.backend.Backend.requestSetStreamLocation(Backend.java:204)
                                                                at com.livestreamsdk.amazon.AmazonSender$1.onComplete(AmazonSender.java:90)
                                                                at com.livestreamsdk.backend.Backend$BackendRunnable.run(Backend.java:319)
                                                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                at java.lang.Thread.run(Thread.java:818)

app crashes when click on red record button

com.livestreamsdk.example E/EYEYE: <Nine00SecondsSDK$1> org.json.JSONException: Value Forbidden of type java.lang.String cannot be converted to JSONObject
at org.json.JSON.typeMismatch(JSON.java:111)
at org.json.JSONObject.(JSONObject.java:159)
at org.json.JSONObject.(JSONObject.java:172)
at com.livestreamsdk.Nine00SecondsSDK$1.onComplete(Nine00SecondsSDK.java:104)
at com.livestreamsdk.backend.Backend$BackendRunnable.run(Backend.java:319)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Front Camera Support

Hi,

I am trying to display front camera previews.
Currently, I am facing an issue while doing so as it is not able to access front cameras. It connects to only back camera. Is this possible using 900SecondsSDK-Android?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.