Skip to content

Commit

Permalink
Update Android Studio 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed May 4, 2019
1 parent 99fca43 commit 38da5bb
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 79 deletions.
98 changes: 65 additions & 33 deletions app/app.iml

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions app/src/main/java/com/haishinkit/studio/CameraTabFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.haishinkit.studio

import android.Manifest
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -14,6 +15,10 @@ import com.haishinkit.media.Audio
import com.haishinkit.events.Event
import com.haishinkit.util.EventUtils
import com.haishinkit.view.CameraView
import android.Manifest.permission
import android.support.v4.app.ActivityCompat
import android.content.pm.PackageManager
import android.support.v4.content.ContextCompat

class CameraTabFragment: Fragment(), IEventListener {
private var connection: RTMPConnection? = null
Expand All @@ -22,18 +27,25 @@ class CameraTabFragment: Fragment(), IEventListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val permissionCheck = ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA)
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.CAMERA), 1)
}
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.RECORD_AUDIO), 1)
}
connection = RTMPConnection()
stream = RTMPStream(connection!!)
stream?.attachCamera(Camera(android.hardware.Camera.open()))
stream?.attachAudio(Audio())
stream?.attachCamera(Camera(android.hardware.Camera.open()))
connection?.addEventListener("rtmpStatus", this)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val v = inflater!!.inflate(R.layout.fragment_camera, container, false)
val button = v.findViewById<Button>(R.id.button)
button.setOnClickListener {
connection?.connect("rtmp:https://192.168.11.15/live")
connection?.connect("rtmp:https://192.168.11.15:1935/live")
}
cameraView = v.findViewById<CameraView>(R.id.camera)
cameraView?.attachStream(stream!!)
Expand All @@ -44,7 +56,7 @@ class CameraTabFragment: Fragment(), IEventListener {
val data = EventUtils.toMap(event)
val code = data["code"].toString()
if (code == RTMPConnection.Code.CONNECT_SUCCESS.rawValue) {
stream!!.publish("live")
stream?.publish("live")
}
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.31'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Oct 27 18:59:43 JST 2018
#Sat May 04 00:47:57 JST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\:https://services.gradle.org/distributions/gradle-5.1.1-all.zip
2 changes: 1 addition & 1 deletion haishinkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
compile 'commons-io:commons-io:2.5'
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
Expand Down
Loading

0 comments on commit 38da5bb

Please sign in to comment.